magento中有用的代码片段-不断更新…
magento中如何获取购物车的产品和总价
<?
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->__('Items: %s',$count);
}
if($count==1)
{
echo $this->__(' Item: %s',$count);
}
if($count>1)
{
echo $this->__(' Items: %s',$count);
}
echo $this->__(' Total: %s', $this->helper('core')->formatPrice($total, false));
?>
magento中获得优惠总额
magento中获得优惠总额
<?php $result=0; $quote=Mage::getSingleton('checkout/session')->getQuote(); foreach ($quote->getAllItems() as $item){ $result+= $item->getDiscountAmount(); } echo $result; ?>
Magento获取产品自定义属性及对应的值
1、如果你新增的属性为文本或文本域类型(Text Field or Text Area),那么你的代码应为:
< ?php echo $_product->getAttributeName() ?>
如我添加一个shoe_size的属性,那么你的调用代码应写成下面格式:getShoeSize()?>
2、如果你新增的属性为下拉菜单类型(Dropdown)和多项选择类型(Multiple Select),那么你的代码应写成下面格式:
< ?php echo $_product->getAttributeText(‘shoe_size’) ?>
产品编号(sku):htmlEscape($_product->getSku()) ?>