Javascript 在标题中显示“我的购物车”中的产品编号-Magento
我想在magento的标题中显示购物车的产品数量。我发现了一些代码 ` 并在Top.phtml中使用它 表现得很好。但问题是,要在每次删除缓存时在购物车中显示正确的数据产品总数。我只是想,它不应该依赖于缓存,就像在magento中它如何改变侧栏上的计数一样,它也应该改变标题,不应该依赖于缓存。我正在使用Magento 1.4.1。如果有人能帮忙的话,这件事很紧急。。提前谢谢你,朋友Javascript 在标题中显示“我的购物车”中的产品编号-Magento,javascript,jquery,magento,Javascript,Jquery,Magento,我想在magento的标题中显示购物车的产品数量。我发现了一些代码 ` 并在Top.phtml中使用它 表现得很好。但问题是,要在每次删除缓存时在购物车中显示正确的数据产品总数。我只是想,它不应该依赖于缓存,就像在magento中它如何改变侧栏上的计数一样,它也应该改变标题,不应该依赖于缓存。我正在使用Magento 1.4.1。如果有人能帮忙的话,这件事很紧急。。提前谢谢你,朋友 echo Mage::helper('checkout/cart')->getItemsCount();
echo Mage::helper('checkout/cart')->getItemsCount();
应该可以了。1.goto app->code->core->mage->checkout->block->links.php 2.编辑如下代码 $count=Mage::helper'checkout/cart'->getItemsCount` 如果$count>=1 { $text=$this->\uuuuu'Mycart%s items',$count } 否则 { $text=$this->_uuuu'Mycart' }用于显示购物车中的产品数量
虽然我现在使用的是1.5.0.0,但我从来没有遇到过缓存问题,你能试试Mage::getSingleton'checkout/session'->getQuote->getAllItems->count吗?这个函数存在于1.9.3.8中。我想更新你的MaGeto版本。
echo Mage::helper('checkout/cart')->getItemsCount();
<?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));
?>