1

the issue I have is when trying to apply a discount to the order from checkout, it will apply the right total discount at the bottom of the magento admin order page, but the line items are showing $0 discount.

for example lets say I have a promotion for 50% on everything and someone buys 2 items, Apple for $10 and Orange for $5 the cart total would be 15 - 50% = $7.50 which is already happening, but then when you look at the line items both discount is set to $0 where it should be : apple qty: 1 price $10 discount $5 total $5 orange qty: 1 price $5 discount 2.50 total $2.50 ; here is my code :

 $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;
user1920187
  • 802
  • 1
  • 7
  • 15

1 Answers1

0

Is the cart promotional rule set to discount on a per item discount or for the whole order?

The code itself looks ok.

You may also wish to add for the checkout session.

Mage::getSingleton("checkout/session")->setData("coupon_code",strlen($couponCode));
elfling
  • 645
  • 5
  • 10
  • Hi Thanks for the suggestion, its not the promo rule it self as it only does it for this specific payment method (custom created) I think it may have to do with the observer – user1920187 Aug 08 '13 at 17:59