2013-08-01 57 views
0

我遇到的问题是,当尝试将结算中的订单应用折扣时,它会在magento管理订单页面底部应用正确的总折扣,但订单项显示$ 0折扣。Magento折扣没有显示在订单项上,但总计是正确的

例如,可以说我有50%的促销活动,有人购买2件商品,苹果公司购买10美元,橙色购买5美元购物车总额为15-50%= 7.50美元,这已经发生了,但是当你看看行项目折扣设置为0,它应该是:苹果数量:1价格10美元折扣5美元总计5美元 橙色数量:1价格5美元折扣2.50美元总计2.50美元;这里是我的代码:

$couponCode = (string) $this->getRequest()->getParam('coupon_code'); 
    if ($this->getRequest()->getParam('remove') == 1) { 
     $couponCode = ''; 
    } 
    $oldCouponCode = $this->_getQuote()->getCouponCode(); 

    if (!strlen($couponCode) && !strlen($oldCouponCode)) { 
     $this->_goBack(); 
     return; 
    } 

    try { 
     $this->_getQuote()->getShippingAddress()->setCollectShippingRates(true); 
     $this->_getQuote()->setCouponCode(strlen($couponCode) ? $couponCode : '') 
      ->collectTotals() 
      ->save(); 

     if ($couponCode) { 
      if ($couponCode == $this->_getQuote()->getCouponCode()) { 
       $this->_getSession()->addSuccess(
        $this->__('Coupon code "%s" was applied.', Mage::helper('core')->htmlspecialchars($couponCode)) 
       ); 
      } 
      else { 
       $this->_getSession()->addError(
        $this->__('Coupon code "%s" is not valid.', Mage::helper('core')->htmlspecialchars($couponCode)) 
       ); 
      } 
     } else { 
      $this->_getSession()->addSuccess($this->__('Coupon code was canceled.')); 
     } 


    echo $this->_getReviewHtml(); 
    exit; 

回答

0

购物车促销规则是否设置为每件商品折扣或整个订单的折扣?

代码本身看起来不错。

您也可能希望添加结帐会话。

Mage::getSingleton("checkout/session")->setData("coupon_code",strlen($couponCode)); 
+0

嗨感谢您的建议,它不是促销规则它自己,因为它只对这种特定的付款方式(自定义创建)我认为它可能与观察员 – user1920187