We have created multiple shopping cart price rules and they have been applied to the user.

In a single cart for a user, multiple shopping cart price rules have been applied. By default Magento can retrieve the total discount amount. But I would like to retrieve the individual discounts (name, amount) for a cart.

Example: in one cart, 3 discounts applied ( 10% offer, 20% offer on bikes, 25% offer), we can only get the total discount after those discounts have been applied. I would like to retrieve the values of each individual discount, i.e. the amount for the 10% discount and so on.

1 Answer 1


This is more complex than it might sound, because the amounts of the individual discount types are not saved in the quote, only the names and the total discount (per item and per cart)

I wrote an module for it, it's not ready to be released but I can highlight the steps I followed to give you a rough impression:

  • add quote attributes which contain the serialized discount information: discount_description_array, discount_amount_array, base_discount_description_array, base_discount_amount_array
  • populate the attributes in observers for sales_quote_address_collect_totals_before (initialize), salesrule_validator_process (add data) and sales_quote_address_collect_totals_after (finalize)
  • rewrite the totals block tax/checkout_discount and replace the discount total object in the totals array with individual entries.

Additionally, if you want to show individual discounts in orders, invoices and credit memos as well:

  • create same attributes for orders, invoices and credit memos and copy them on conversion
  • fall back to total discount if sum does not match (i.e. for partial invoices)
  • rewrite the totals blocks sales/order_totals, sales/order_invoice_totals, sales/order_creditmemo_totals

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.