Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Magento display multiple discounts in cart

I am currently looking for a way to display multiple discounts in the Magento shopping cart without having to buy an extension. If a customer is purchasing an order over $50 then shipping is free, if they use coupon code "rush13" then they get a 10% discount. The shipping price and discount are both calculating correctly but they are showing up on one line. Is there a way display the discounts broken down? I feel this would be easier on the customer to see how much they are receiving for each discount.

I'm using Magento 1.7

--Current Display--

Subtotal: $xxx.xx

Discount (Free Shipping, Applied Coupon Code RUSH13) -$xx.xx

--Preferred Display--

Subtotal: $xxx.xx

Discount(Free Shipping) -$xx.xx

Discount(Coupon Code RUSH13) -$xx.xx

--This Could Also Work --

Subtotal: $xxx.xx

Discount(Free Shipping -$xx.xx, Coupon Code RUSH13 -$xx.xx) -$xx.xx

Any help would be appreciated. I don't like posting questions without code here but I'm not sure where to start on this one. Thanks in advance.

like image 624
Matt Avatar asked Jun 05 '13 15:06

Matt


1 Answers

class Mage_SalesRule_Model_Validator is responsible for discount calculation. So we can set our Discount Description from this looped calculation.

in the method

public function process(Mage_Sales_Model_Quote_Item_Abstract $item)

look for the code

$discountAmount = $result->getDiscountAmount();

and place these 2 lines after above code which will prepare our description array in current foreach loop

$_formatedDiscountAmount = Mage::helper('core')->currency($discountAmount, true, false);
$_descriptionArray[] = $rule->getName()."-".$_formatedDiscountAmount;

and at last, right after the end of the foreach place this code

$address->setDiscountDescriptionArray($_descriptionArray);
like image 138
Deependra Singh Avatar answered Oct 03 '22 06:10

Deependra Singh