- Issue created by @vipin.j
- Status changed to Needs review
4 months ago 9:58am 30 August 2024 - Status changed to Needs work
4 months ago 10:47am 30 August 2024 - 🇳🇴Norway zaporylie
What I am missing here is a slightly better explanation of why we need this feature in the Commerce Core. Based on the current state of MR it seems to address specific project requirements -
unset($form['display_inclusive']);
,'#max' => 1000,
, etc.Should it only be limited to a percentage off?
- 🇮🇳India vipin.j
@zaporylie, The current available offer plugins have limitation that a site administrator cannot restrict its users to redeem a coupon with percentage discount to a fixed quantity for an order item in checkout.
For example; suppose you got a coupon with 100% discount for a product variation. now, the site admin expects this coupon to redeem only for 1N quantity for the same order item. but, in fact with 100% discount you can even buy 10N quantity of that and place an order, and the system won't blocks you. Also, we can not go with the "Fixed amount off..." offer plugin too, because the product price may change after the coupon has been bought by the customer. The same conversation we had in #slack discussion
unset($form['display_inclusive']);
: This was done because if you calculates a certain percentage of discount with a given coupon, and then update the unit price of the order item in the order checkout, then in practically that doesn't make sense with quantity validation. as the unit price has now been updated to the discounted amount and if you block that amount for say 1N quantity, then the rest of the quantity will also get multiplied by the same amount. So, basically with a configured number of quantity validation when a coupon gets redeemed than the calculated discount must only be applied to that quantity only and the rest of the quantity should then multiplied to the original unit price.'#max' => 1000,
: We just kept it to the max number, because with our use case a teacher can buy 100 coupons too for a digital product, that's it. - 🇺🇸United States morbus iff
Some code comments:
- I'd remove the
#max
entirely. - I think I'd change the promotion label to "Percentage off each matching product with fixed quantity". Or potentially shorter: "Percentage off each matching fixed quantity product".
- Same "to" to "with" change for the file documentation header.
- We're likely gonna need some tests.
- Too much closing bracket indent spacing in defaultConfiguration().
- I think I'd labeled "Max quantity" to just "Quantity". Maximum is implied.
- We can likely get rid of the #description too - it's all implied as part of the promotion label.
- The "Quantity must be a positive number." message could be replaced with "Quantity must be higher than or equal to 1." which is a similar error that is tested against in AddToCartFormTest.php.
- I'd remove the
- Status changed to Needs review
3 months ago 1:15pm 13 September 2024