How to block all Shopify discounts code during sales promotion?

Discount compounding becomes a problem when you have promotional sales activities and customers have coupon codes that were previously shared via newsletter or other channels.

You have several options to avoid “double discounting” while you run your promotion:

This can be very time consuming if you have a high number of active coupons.

  • This way the customer will be able to only use 1 coupon code.
  • Example: Instead of applying a 20% strike-through price, also known as sale price, you can create a coupon that provides a 20% discount on specific products. The downside here is that you don’t make the promo visible automatically in the price which will affect your promotion conversion rate.

You can install the official Shopify scripts app here (it only works for Shopify Plus plans)

REJECTION_MESSAGE = 'Discount codes cannot be used during this sale'
class DisableDiscountCodesCampaign
  def initialize(rejection_message)
    @rejection_message = rejection_message

  def run(cart)
    return if cart.discount_code.nil?

    cart.discount_code.reject(message: @rejection_message)


CAMPAIGNS.each do |campaign|

Output.cart = Input.cart


This is an example code that can be further optimized to only reject discounts on specific products or collections. If you need a special Shopify script for a specific use case, send us a message and we will help you out.

For example:

  • Conditional discount – only reject coupon code if sale products are in the cart or only reject specific coupon codes.

Are you ready to grow
your Shopify Store?

Get in touch