blog
Shopify merchants looking to exclude discount codes for specific products can use two solutions. The CSS method hides the discount form for selected items, while Shopify Scripts can be used to reject the discount code for products with specific tags. Both approaches help you control which products are eligible for discounts, improving the flexibility of your store’s promotions.
It's been requested by multiple enterprise clients to remove discount code for particular products.
We thought to have 2 solution
[data-reduction-form="update"] {
display: none
}
#Reject Discount for few products
reject = false
Input.cart.line_items.select do |line_item|
product = line_item.variant.product
if product.tags.include?('reject_code')
reject = true
end
end
if reject and Input.cart.discount_code
Input.cart.discount_code.reject(
message: "discount can't applied! for this product."
)
end
Output.cart = Input.cart
One-stop solution for next-gen tech.