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;