Magento以编程方式申请优惠券但其印刷价值

时间:2014-06-25 18:55:35

标签: php magento

我正在使用

Mage::getSingleton('checkout/cart')->getQuote()->getShippingAddress()
    ->setCollectShippingRates(true);
Mage::getSingleton('checkout/cart')->getQuote()
    ->setCouponCode($xfCouponCode)->collectTotals()->save();

我可以完美地申请优惠券,但

Mage::getSingleton('checkout/cart')->getQuote()
    ->setCouponCode($xfCouponCode)->collectTotals()->save();

此行然后在模板中运行echo优惠券。我不知道为什么在模板中回复优惠券..

1 个答案:

答案 0 :(得分:0)

在输入字段中的coupon.phtml中显示优惠券jus评论... ho $ this-> htmlEscape($ this-> getCouponCode())

<div class="input-box">
                <input class="input-text" id="coupon_code" name="coupon_code" value="<?php //echo $this->htmlEscape($this->getCouponCode()) ?>" />
            </div>

MODI

fy copon code 
    $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();
    }