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;
    }

次に、ショッピング カートの数量にタグを適用します。そのため、My Shopping Bag 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 に答える