我正在尝试为购物车重写模板。
我需要检索折扣金额,但找不到在哪里。
即,如果我的优惠券代码给了我 10 美元的折扣,我想取回 10,如果我有 5% 的折扣,如果总价为 100 美元,我想取回 5。
谢谢你。
您可以通过打印出来并观察它包含的值来调试您的对象
print_r($this->getQuote()->getData());
我使用以下代码访问折扣价。我正在访问 phtml 文件中最后一个订单的详细信息。对于最后一个订单,如果使用了折扣券,那么我使用以下代码访问折扣金额。
$lastOrderId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
$order=Mage::getModel('sales/order')->loadByIncrementID($lastOrderId);
if($lastOrderId) //If order was placed then only display coupon code
{
$coupon=$order->getCouponCode();
echo "<b>Discount coupon used during order:</b>".$coupon;
$disAmount=$order->getDiscountAmount();
echo "<br/>Discount Amount: ".$disAmount;
}