0

我已通过以下代码将顶部链接中的文本“我的购物车”更改为“我的购物袋”。

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(数量)应该是红色的。所以我该怎么做?

4

2 回答 2

0

您的代码是正确的,但在其他方面它需要棘手的方式。你可以这样显示 $text = $this->__('My Shopping Bag (0)'); 可以帮助你

谢谢阿南德

于 2013-09-14T11:05:22.237 回答
0

对不起,愚蠢的问题。

可以直接添加。

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;
    }
于 2013-05-03T05:53:17.820 回答