本文介绍了Magento以编程方式应用优惠券,但其印刷价值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用
Mage::getSingleton('checkout/cart')->getQuote()->getShippingAddress()
->setCollectShippingRates(true);
Mage::getSingleton('checkout/cart')->getQuote()
->setCouponCode($xfCouponCode)->collectTotals()->save();
我可以完美地使用优惠券,但是
i can apply coupon perfectly but when
Mage::getSingleton('checkout/cart')->getQuote()
->setCouponCode($xfCouponCode)->collectTotals()->save();
此行运行,然后在模板中回显优惠券.我不知道为什么在模板中回显优惠券.
this line run then echo coupon in template. i don't know why echo coupon in template..
推荐答案
在输入字段中的coupon.phtml中有显示优惠券,只需将$this->htmlEscape($this->getCouponCode())
注释如下:
In the coupon.phtml in input field have show coupon just comment out $this->htmlEscape($this->getCouponCode())
like this:
<div class="input-box">
<input class="input-text" id="coupon_code" name="coupon_code" value="<?php //echo $this->htmlEscape($this->getCouponCode()) ?>" />
</div>
修改优惠券代码:
$couponCode="amitG";
$oldCouponCode = Mage::getSingleton('checkout/cart')->getQuote()->getCouponCode();
if (strlen($couponCode) && strlen($oldCouponCode)) {
Mage::getSingleton('checkout/cart')->getQuote()-->getShippingAddress()->setCollectShippingRates(true);
Mage::getSingleton('checkout/cart')->getQuote()->setCouponCode(strlen($couponCode) ? $couponCode : '')
->collectTotals()
->save();
}
这篇关于Magento以编程方式应用优惠券,但其印刷价值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!