Drupal 9 image field migration

Black Friday/Week is ongoing, promotions were prepared and already available on production website. But one thing we missed to test is the Compatibility with other promotions options.

We set 15% sale for all products in store. But some of our products need to have 30% cutoff. On products view modes everything works fine - prices displayed with correct promotions. But when customer added to the cart 1 Product from 15% price and other one with 30%, the second one doesnt have promo in the cart at all! Compatibility for main 15% promo was set to "Not with any other promotions". That's was the issue.

Commerce promotion module have a lot of conditions which you can set to promo. But "Negotiation" conditions missed there. I dont know why this simple stuff is not included in contrib module yet. The issue was fixed by simply copying OrderItemProduct condition from commerce_product module to custom and change return value to opposite.

 /**
  * {@inheritdoc}
  */
 public function evaluate(EntityInterface $entity) {
  // ...
   return !in_array($purchased_entity->getProductId(), $product_ids);
 }

So products which have referenced in another promotions (with 30% in this example) should be added to "Negotiation products" reference in main promotion.

Now all our products have 15% promo and some of them 30%.

https://gist.github.com/onesixromcom/72519841752b62ca176a3da405fa8aac

Add new comment

The content of this field is kept private and will not be shown publicly.
  • No HTML tags allowed.
CAPTCHA
       .o8                 .ooooo.                         ooooo   ooooo 
"888 888' `Y88. `888' `888'
.oooo888 oooo ooo 888 888 .oooo.o .ooooo. 888 888
d88' `888 `88. .8' `Vbood888 d88( "8 d88' `"Y8 888ooooo888
888 888 `88..8' 888' `"Y88b. 888 888 888
888 888 `888' .88P' o. )88b 888 .o8 888 888
`Y8bod88P" `8' .oP' 8""888P' `Y8bod8P' o888o o888o


Enter the code depicted in ASCII art style.
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.