This will help us solve #2893367: The Product: Quantity condition doesn't take into account non-combined order items and #2866003: Add a "Buy X Get Y" promotion offer.
Order item offers need a way to identify which order items they will apply to.
Currently this is implicit, an order item offer is given the order items individually by Promotion::apply(), which uses the promotion-level conditions from the "Product" group. That means that the promotion conditions are used for two different questions:
- "Can I be used with this order?" (if it contains product X)
- "Which order items should I apply to" (products X)
Divorcing the two makes the UI more explicit, and makes it easier for us to implement the BOGO offer, which needs two sets of offer conditions. This will require an update hook that updates all promotions, but that's the price of progress.
Comment | File | Size | Author |
---|---|---|---|
#8 | update-message.png | 137.14 KB | bojanz |
#6 | 2980700-6.patch | 23.25 KB | bojanz |
| |||
#5 | 2980700-5.patch | 25.02 KB | bojanz |
| |||
#4 | 2980700-4.patch | 55.53 KB | bojanz |
|
Comments
Comment #2
bojanz CreditAttribution: bojanz at Centarro for Ny Media AS commentedComment #3
bojanz CreditAttribution: bojanz at Centarro for Ny Media AS commentedThe patch has become huge so I've been splitting off and committing parts:
#2981941: Tests are still using the deprecated "amount" setting for order_percentage_off offers
#2893367: The Product: Quantity condition doesn't take into account non-combined order items
#2981944: Re-organize the base offer plugin classes
Main patch to follow.
Comment #4
bojanz CreditAttribution: bojanz at Centarro for Ny Media AS commentedStill needs manual testing of the upgrade path, and a message that shows the user which promotions got disabled, along with a link to the change record.
Summary:
1) Adds order-level conditions for order_item_product, order_item_product_type, order_item_variation_type.
2) Converts the promotion conditions to be order-level only, simplifies the related logic.
3) Adds offer conditions and tests.
4) Updated condition element UX, to skip vertical tabs when there is only one group.
5) Adds an upgrade path, with code that disables promotions that have an unknown order item offer, or have unknown order item conditions combined with an order offer.
Note: We're not checking offer conditions in $promotion->applies(), which means a promotion might apply, but affect no order items. I guess that makes sense?
Comment #5
bojanz CreditAttribution: bojanz at Centarro for Ny Media AS commentedSplit off and committed the order-level conditions in #2982198: Add order-level product/product_type/variation_type conditions. Added the forgotten schema there as well.
Here's a reroll. Much better size.
Comment #6
bojanz CreditAttribution: bojanz at Centarro for Ny Media AS commentedRerolled without #2982202: Update promotion offer UX, which wasn't even described in #4.
Added code that forces a "Products" category for every order item condition, cause having a different category name would trigger vertical tabs, destroying the UX.
Comment #8
bojanz CreditAttribution: bojanz at Centarro for Ny Media AS commentedUpdate function tested, retested, debugged. Screenshot attached.
Change record created, commit pushed.