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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

bojanz created an issue. See original summary.

bojanz’s picture

Issue tags: +ny-bogo
bojanz’s picture

bojanz’s picture

Status: Active » Needs review
FileSize
55.53 KB

Still 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?

bojanz’s picture

Split 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.

bojanz’s picture

Rerolled 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.

  • bojanz committed 06497cd on 8.x-2.x
    Issue #2980700 by bojanz: Introduce offer conditions
    
bojanz’s picture

Status: Needs review » Fixed
FileSize
137.14 KB

Update function tested, retested, debugged. Screenshot attached.

Change record created, commit pushed.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.