Magento - 在Toplinks中显示购物车图像而不是“我的购物车”


Magento - Display shoppingcart image instead of "My Cart" in Toplinks?

我正在尝试显示购物车图像而不是"我的购物车"短语。购物车图像上方仅显示购物车中的商品数量。

要更改文本,必须编辑法师/结帐/阻止/链接.php这部分:

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 Cart (%s item)', $count);
        } elseif ($count > 0) {
            $text = $this->__('My Cart (%s items)', $count);
        } else {
            $text = $this->__('My Cart (0 items)');
        }

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->__('</span></span>%s</span></span>', $count);
        } elseif ($count > 0) {
            $text = $this->__('<span><span>%s</span></span>', $count);
        } else {
            $text = $this->__('<span><span>0'</span></span>);
        }

因此,现在商品编号显示在购物车图像的内部/上方。正如我所希望的那样。问题是:通过将鼠标悬停在链接上,它现在显示项目编号前后的跨度跨度标签。

知道如何在那里更改该链接标题吗?或者,也许有更好的方法来在顶部链接中显示购物车图像?

在Magento源代码中引用的块下方,我看到这一行:

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

尝试为$text给出的两个值提供不同的值 - 我敢打赌其中一个是链接的 HTML,另一个是工具提示文本。 (为了保持一致性,您可能也应该对新文本使用$this->__() - 尽管它不太可能产生任何影响,因为它的作用是允许Magento将该文本翻译成另一种语言。 然后,您可以在 HTML 版本中设置跨度,同时将它们排除在工具提示之外。