Personalized checkout and custom promotions with Shopify Scripts
We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more
I am using script editor which is made by Shopify.
I want to disable discount codes for products that have "no_discount" tag.
But I have some problem.
For example, if there are 4 products in the cart.
And only one product has "no_discount" tag.
In this case, let's imagine I use a discount code that discount by 10%.
I want to prevent discount for only the product which has "no_discount" tag.
And discount for other three products by 10%.
Is it possible?
If you're using discount codes, you don't even need the script editor. Create a collection with all the items that are eligible for the discount, and have the discount code only apply to that collection. (Note that Shopify cannot EXCLUDE items from a smart collection based on tags, so you would need to tag eligible products rather than ineligible products.)
If you're apply the discount via line item script, I assume you're looping through each item in the cart. Before applying the discount to the line item, add an "unless" statement similar to this:
unless line_item.variant.product.tags.include?('no_discount')
Don't forget to end your unless loop!