This is an added feature to support discount offer percentage off with maximum amount price (screenshot field: Selection_131.png).
For example: admin create discount with 10% off and have maximum amount 10 USD.
Case A: customer has order total 200 USD.
Discount amount calculation: 10% * 200 = 20 USD.
Because discount amount higher than maximum amount, the discount amount for customer is 10 USD.
Case B: customer has order total 50 USD.
Discount amount calculation: 10% * 50 = 5 USD.
Because discount amount lower than maximum amount, the discount amount for customer is 5 USD.
Changes in code:
1. Add field commerce_percentage_maximum with type commerce_price and default value 0.
2. Add discount amount check on rules action apply percentage discount.
| Comment | File | Size | Author |
|---|---|---|---|
| #12 | commerce_discount-discount_percentage_maximum_amount-2543242-12.patch | 8.42 KB | andre4s_y |
| Selection_131.png | 16.48 KB | andre4s_y |

Comments
Comment #1
andre4s_y commentedI have created the patch.
Please help to review. :)
Thank you.
Comment #2
joelpittetSetting to needs review so testbot has a chance to review.
Though this likely should go this maybe? https://www.drupal.org/project/commerce_discount_extra
Comment #4
andre4s_y commentedUps, my bad.
Update the patch: fix default value amount for commerce_percentage_maximum instance.
I have no idea whether this feature belong to discount or discount extra.
But IMO, this feature is usefull. :)
Comment #6
andre4s_y commentedUpdates:
Comment #8
andre4s_y commentedUpdate: fix create percentage offer discount and use maximum amount $20 for test cases.
Comment #10
andre4s_y commentedUpdate: change percentage maximum amount value to $0.2 at test cases.
Test cases use product amount $10.
If the discount percentage value is 5% and without maximum amount, the discount amount will be $0.5.
If the discount percentage value is 5% and with maximum amount $0.2, the discount amount will be $0.2.
Comment #12
andre4s_y commentedUpdate: fix product discount maximum amount calculation.
Comment #13
joelpittetComment #14
joelpittetAs this feature could easily cause some confusion to customers, is there maybe a way you can present that maximum has been reached in the order on the component title maybe?
Sorry but I'm a bit hesitant on this feature.
Thanks for adding tests though, that is awesome!.
Comment #15
andre4s_y commentedYou have 100% valid argument. This feature did create confusion to customer, I know it because I have already implemented. :D
Only marketing people found this useful. I will work on it, but of course the decision is yours. :)
Comment #16
joelpittetMaybe worth adding to commerce_discount_extras, just a thought.
I can see where they may want to limit the discount but marketing needs to be a bit more explicit in what users are to expect. Which as you know isn't easy in commerce architecture to do in all cases but may be possible if thought through, just kinda hard and maybe messy/ugly.
Fine print incentives can turn off customers but Canadian tv/internet providers do it all the time!