0

Hoping someone has tackled this problem before me, and can help me save some time. I am working on a project that has a custom discount structure, to complex for the built in promotions logic so to handle that we're assigning that discount manually via an observer, on the event sales_quote_collect_totals_after. This worked fine, up until I ran a test with a 2nd discount, a manual code, that gave a 10% discount.

Both discounts co-exist fine, however they're being applied in the reverse order for example...

Base Price: $23.97
Discount: -10% ($2.397)
Plan Discount: -$3.00 (observer)

This should be reversed to the following.

Base Price: $23.97
Plan Discount: -$3.00 (observer)
Discount: -10% ($2.097)

If anyone has any ideas or thoughts on how to move forward with this, I'd greatly appreciate it.

Thanks!

0

The event that is most likely to help you out is sales_quote_address_discount_item

It is called in Mage_Sales_Model_Quote_Address_Total_Discount and Mage_SalesRule_Model_Quote_Discount for each item of the quote.

The event comes with 4 arguments:

  • website_id
  • customer_group_id
  • coupon_code
  • item

The Mage_SalesRule_Model_Quote_Discount class is most likely the one responsible for generating your discounts (unless you have 3rd party modules) and if you look in there you will see the event is thrown right before it runs the sales rules code that will generate a discount based on the coupon_code.

0

I am not sure if sales_quote_address_collect_totals_before is going to help you since all totals are set to 0 when this event is dispatched. Try using event: sales_quote_address_discount_item

  • Because one is created in an observer, thus far I am lead to believe the actual priorities don't work as intended. I made the manually entered code as "9999999" and still am having trouble. – Johnathon Mathews Aug 12 '15 at 15:37
  • @JohnathonMathews see edit – Paras Sood Aug 12 '15 at 15:59
  • Yea, that's what's been recommended. I am not seeing many people use it in tutorials for adding a coupon. So guess it looks like I am on my own to figure out how to use the two together. – Johnathon Mathews Aug 12 '15 at 16:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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