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

Reject Discount Code for Few Products in Shopify Plus Checkout

Aashish Kasma|April 2, 2018|0 Minute read|Listen
Checkout CustomizationShopify 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

  • [](https://gist.github.com/ashukasma/a01df83ece9b869815965cf4bf6297b7#file-reject-discount-for-few-products-css)[](https://gist.github.com/ashukasma/a01df83ece9b869815965cf4bf6297b7#file-reject-discount-for-few-products-css)CSS Solution

[data-reduction-form="update"] { display: none }

  • [](https://gist.github.com/ashukasma/a01df83ece9b869815965cf4bf6297b7#file-reject-discount-for-few-products-css)[](https://gist.github.com/ashukasma/a01df83ece9b869815965cf4bf6297b7#file-reject-discount-for-few-products-css)Shopify Scripts

#Reject Discount for few products reject = false Input.cart.lineitems.select do |lineitem| product = lineitem.variant.product if product.tags.include?('rejectcode') reject = true end end

if reject and Input.cart.discountcode Input.cart.discountcode.reject( message: "discount can't applied! for this product." ) end Output.cart = Input.cart

SHARE

Aashish Kasma
Aashish Kasma
Co-founder & CTO, Lucent Innovation
linkedinmediumdevtohashnode

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.

Start the Conversation