0

Using Drupal9 and Commerce2 I'm trying to configure shipping for a specific variation type : tires.

If you order one or 2 tires, you must pick them up on site. if you order 4 or more, they can be shipped for free. there is no intermediate possibility, no possibility of shipping with postage if you buy less than 4.

So I configured the type of variation by not checking the "shippable" box.

Now in a CartEventSubscriber, I would like to be able to change the value of "shippable" from the moment there are 4 items of this type (or more) in the cart.

When I add a product to the cart, I can't find any trace of the shippable property in the item or in the variation...

public function addToCart(CartEntityAddEvent $event) {
  $order_item = $event -> getOrderItem();
  $variation = $order_item -> getPurchasedEntity();
        
  dpm($order_item);
  dpm($variation);
}

Does anyone have an idea how to achieve the result I need?

Thanks in advance for your answers.

1

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.