Reject Discount Code for Few Products in Shopify Plus Checkout
Checkout Customization · Shopify Plus

Reject Discount Code for Few Products in Shopify Plus Checkout

Ashish Kasama|April 2, 2018|0 Minute read|Listen
Checkout Customization Shopify Plus
TL;DR

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

    SHARE

    Ashish Kasama
    Ashish Kasama
    Co-founder & Your Technology Partner

    Facing a Challenge? Let's Talk.

    Whether it's AI, data engineering, or commerce tell us what's not working yet. Our team will respond within 1 business day.