magento得到您的购物车总积分
问题描述:
我一直在这里像疯了googling ..我想要一个简单的事情。从购物车中所有产品的特殊/尝试/调整价格总和中,以正常价格获得所有产品总价格的差额。magento得到您的购物车总积分
IE:如果我在那有像
1 @ $5
2 @ $10
--------------------------
total = $15 Savings = $0
但我然后我就#2一个特殊的价格正常价格属性拖车2项所以车是
1 @ $5
2 @ $5
--------------------------
total = $10 Savings = $5
现在我知道我可以使用
$this->helper('checkout')->formatPrice(Mage::getSingleton('checkout/cart')->getQuote()->getGrandTotal());
要获得总计,但我不是100%,是不是没有航运..但日在将与特殊的价格适用。我会需要总的正常成本,然后我可以从那里做简单的数学计算。
我想要做的是把这些数字在标题和侧栏..想法?
答
产品视图页面
<?php
$_product = $this->getProduct(); ?>
if ($_product->getTypeId() == 'bundle'){
list($_minimalPrice, $_maximalPrice) = $_product->getPriceModel()->getPrices($_product);
$this->_price = $_minimalPrice;
$this->_specialPrice = $_minimalPrice;
if (!is_null($_product->getData('special_price')) && ($_product->getData('special_price') < 100)){
$this->_regularPrice = ($this->_specialPrice/$_product->getData('special_price')) * 100;
} else {
$this->_regularPrice = $this->_specialPrice;
}
} else {
$this->_price = 0;
$this->_regularPrice = $_product->getPrice();
$this->_specialPrice = $_product->getFinalPrice();
}
if ($this->_specialPrice != $this->_regularPrice)
{
if ($this->_regularPrice > 0)
{
$this->_discountAmount = round((1 - $this->_specialPrice/$this->_regularPrice) * 100);
$this->_saveAmount = $this->_regularPrice - $this->_specialPrice;
}
}
if ($this->_regularPrice)
{
$this->_regularPrice = strip_tags(Mage::app()->getStore()->convertPrice($this->_regularPrice, true));
}
if ($this->_specialPrice)
{
$this->_specialPrice = strip_tags(Mage::app()->getStore()->convertPrice($this->_specialPrice, true));
}
if ($this->_saveAmount)
{
$this->_saveAmount = strip_tags(Mage::app()->getStore()->convertPrice($this->_saveAmount, true) );
}
if ($this->_discountAmount)
{
$this->_discountAmount = $this->_discountAmount . '%';
}
上如此,还有_saveAmount
和_discountAmount
,在模板中使用,但我没有测试它,小心在生产现场。
你好,这确实能够显示当前产品在%和$中的节省量,但这不是我想要弄清楚的。我猜想必须有一种方法来列出购物车中的产品列表,然后对其进行迭代并执行此数学运算,但是我认为它有一个更快/更精简的路径,因为它在头脑中。 – 2012-01-29 18:12:22
您是否在购物车页面中尝试过此片段? – 2012-01-30 13:38:56
也,你提到的是正确的,你应该重复购物车部分的产品收集。 – 2012-01-30 13:39:33