-1

我想在 magento 的 Header 中将产品数量显示为“我的购物车”。行动我发现一些代码为`

 $count = $this->helper('checkout/cart')->getSummaryCount();
 $total = $this->helper('checkout/cart')->getQuote()->getGrandTotal();
 if($count==0)
 {
     echo "0";
 }
 if($count==1)
 {
     echo $this->__('%s',$count);
 }
 if($count>1)
 {
     echo $this->__('%s',$count);
 }

并在 Top.phtml 中使用它。

发挥其工作正常。但问题是,每次我必须删除缓存时显示正确的数据(购物车中的产品总数)。我只是想要,它不应该依赖于缓存,就像在magento中它如何改变侧栏上的计数一样,它也应该改变标题,不应该依赖于缓存。我正在使用 Magento 1.4.1。它非常紧急,如果有人可以提供帮助.. 提前感谢 Friendz..

4

3 回答 3

2

1.goto app->code->core->mage->checkout->block->links.php

2.编辑如下代码

$count=Mage::helper('checkout/cart')->getItemsCount();`

如果($count>=1){

$text=$this->__('Mycart(%s items)',$count);

}

别的

{

$text=$this->__('Mycart');

}

于 2012-12-09T20:03:34.900 回答
0
echo Mage::helper('checkout/cart')->getItemsCount();

应该做的伎俩。

于 2012-07-23T22:07:55.117 回答
0

用于显示购物车中的产品数量

<?php
  $count = $this->helper('checkout/cart')->getSummaryCount();  //get total items in cart
  $total = $this->helper('checkout/cart')->getQuote()->getGrandTotal(); //get total price
  if($count==0)
  {
    echo $this->__('<a href="/checkout/cart" class="cartgo">(0 ITEMS)</a>',$count);
  }
  if($count==1)
  {
    echo $this->__('<a href="/checkout/cart" class="cartgo">(1 ITEM)</a>',$count);
  }
  if($count>1)
  {
    echo $this->__('<a href="/checkout/cart" class="cartgo">(%s ITMES)</a>',$count);
  }
  echo $this->__('', $this->helper('core')->formatPrice($total, false));
?>
于 2015-09-15T10:59:25.633 回答