Fabian Blechschmidt
Fabian Blechschmidt

Reputation: 4141

Shopware 6: How to forbid products with an app

Is it possible with a Shopware App (not a plugin!), to forbid certain products?

Example: I'm selling stuff with shipment in small stuff (DHL/UPS) and big stuff, with "your own truck" and I don't want to mix this in one order.

There is no event "product add to cart", so is there any possibility to throw an exception if the customer adds a certain product, based on the products already in the cart?

Upvotes: 0

Views: 106

Answers (2)

Timo Helmke
Timo Helmke

Reputation: 402

That should work without even the need of an app. Add a custom field to the products with fixed options to select the carrier or something like "package", "self-pickup" and so on. Afterwards configure rules for the shipping methods that check this custom field and enable the shipping method for packages only when no product with the custom field value "self-pickup" is in cart and vice versa. that should block the shipping method selection and when there is no shipping method it's not possible to order.

Upvotes: 1

LastSgt
LastSgt

Reputation: 417

This should be doable with App Scripts. Here is the documentation about removing line items from the cart.

https://developer.shopware.com/docs/guides/plugins/apps/app-scripts/cart-manipulation#remove-a-line-item

Upvotes: 2

Related Questions