Preventing order-level discounts from activating when certain items are in cart or based on other conditions

We have a scenario where certain items in the cart (e.g. buying gift cards) should not be subjected to order-level discounts or promotions. However, order-level automatic discounts don’t seem to have any way to prevent them from applying based on the contents of the cart, nor does checkout blocks support this in the rules it provides for discounts.

Is there any way to either make an order-level automatic discount not apply if certain items are in the cart or to have some alternative way to nullify the discount with custom code? The existing Shopify functions APIs also do not seem to provide any way to nullify other discounts, only add new ones.

Hi there!

Yes, you can do this with Order Discounts.

Order discount have excludedVariantIds option for the target. OrderSubtotalTarget

You pass the gift product variant id and it will not apply to gift product.

If you want to use a free app to achieve this, you can install function creator app.

Thanks