如何将标签应用< span>到我的购物车顶部链接在magento?

cl25kdpy  于 2022-11-12  发布在  其他
关注(0)|答案(2)|浏览(100)

我已经通过下面代码将顶部链接中文本.我购物车.更改为.我购物袋.

public function addCartLink()
{
        $parentBlock = $this->getParentBlock();
        if ($parentBlock && Mage::helper('core')->isModuleOutputEnabled('Mage_Checkout')) {
            $count = $this->getSummaryQty() ? $this->getSummaryQty()
                : $this->helper('checkout/cart')->getSummaryCount();
            if ($count == 1) {
                $text = $this->__('My Shopping Bag (%s)', $count);
            } elseif ($count > 0) {
                $text = $this->__('My Shopping Bag (%s)', $count);
            } else {
                $text = $this->__('My Shopping Bag');
            }

            $parentBlock->removeLinkByUrl($this->getUrl('checkout/cart'));
            $parentBlock->addLink($text, 'checkout/cart', $text, true, array(), 50, null, 'class="top-link-cart"');
        }
        return $this;
    }

现在,我想应用标签到购物车数量。所以,它应该看起来像我的购物袋0。0(数量)应该是红色的颜色。那么我该怎么办?

am46iovg

am46iovg1#

你的代码是正确的,但在其他部分它需要巧妙的方式。你可以这样显示$text = $this-〉__('My Shopping Bag(0)');愿它能帮助你
谢谢阿南德

ylamdve6

ylamdve62#

<span>可以直接相加。

public function addCartLink()
{
        $parentBlock = $this->getParentBlock();
        if ($parentBlock && Mage::helper('core')->isModuleOutputEnabled('Mage_Checkout')) {
            $count = $this->getSummaryQty() ? $this->getSummaryQty()
                : $this->helper('checkout/cart')->getSummaryCount();
            if ($count == 1) {
                $text = $this->__('My Shopping Bag <span>(%s)</span>', $count);
            } elseif ($count > 0) {
                $text = $this->__('My Shopping Bag <span>(%s)</span>', $count);
            } else {
                $text = $this->__('My Shopping Bag');
            }

            $parentBlock->removeLinkByUrl($this->getUrl('checkout/cart'));
            $parentBlock->addLink($text, 'checkout/cart', $text, true, array(), 50, null, 'class="top-link-cart"');
        }
        return $this;
    }

相关问题