3

Anyone knows how to group the discounts in Magento? How to set the maximum total discount per group? And how to set the maximum total discount? For example:

Discount Group 1:
a. Early Bird Discount = 10%
b. Member of ABC Organization = 8%
c. Member of BCD Organization = 5%
-----Total Maximum discount for this discount group = 15%

Discount Group 2:
a. Buy more than 5 items = 10%
b. Member of DFG Organization = 5%
c. Member of ASD Organization = 5%
-----Total Maximum discount for this discount group = 15%

-----Total Maximum discount for ALL discount group = 25%
ekad
  • 14,436
  • 26
  • 44
  • 46
maa_ku
  • 111
  • 2
  • 5

1 Answers1

6

Unfourtunatelly there is no possibility to achieve exactly the same functionality you need via standard functionality of Magento. But you can create a customization with your discount groups and validate discount amounts by observing event salesrule_validator_process.

So a bit step by step advice for development:

  1. Create a new model with 2 custom tables that will have such fields:
    • Group Table:
      • group_id - primary key
      • name - Name of group
      • max_discount - Max Discount Amount
      • is_percent - Type (fixed or percent)
    • Group to Rule table
      • group_id - primary_key
      • rule_id - foreign key to sales/rule table primary key  2. Implement admin interface for it
  2. Create configuration field for maximum discount for all groups.
  3. Create observer for the event salesrule_validator_process where your receive such an event with data:
    • $observer->getEvent()->getRule() - model of the currently applying rule
    • $observer->getEvent()->getItem() - current quote item to wich this rule is applied
    • $observer->getEvent()->getAddress() - current quote address to wich this rule is applied
    • $observer->getEvent()->getQuote() - current quote of the customer
    • $observer->getEvent()->getQty() - qty of items that are used for calculation of discounts for: Fixed Item Discount, Percent of item price, To percent of item price
    • $observer->getEvent()->getResult() - Varien_Object with data that is applied as discount, there are two properties for now.
      • getDiscountAmount() - amount of discount in currently displayed currency
      • getBaseDiscountAmount() - amount of discount in base website currency
  4. Realize you logic in observer model. You can track applied rules by storing them in your object and with the next rule apply process - validate groups maximums and change applied discount amounts.
Ivan Chepurnyi
  • 9,233
  • 1
  • 43
  • 43