Shopify Script - Message when user try to stacking discount codes

620 Views Asked by At

Is that possible, via Shopify Script Editor to show a user message when it tries to stack discount codes on the checkout?

I want to allow the user to add any new valid promotion code with regular behavior (attach)

But I want to show a message saying that would not be possible to use 2 discount codes at the same time

My current script is like this:

Output.cart = Input.cart
exit unless Input.cart.discount_code
if Input.cart.discount_code > 1 
  Input.cart.discount_code.reject({ message: 'Only 1 code can be applied at a time' })
end 
Output.cart = Input.cart

Regular Behavior

enter image description here

Thank you in advance

2

There are 2 best solutions below

0
On

Shopify doesn’t allow user to use more than one discount code during checkout, you dont need to worry on this

0
On

The script editor does not allow to stack multiple coupon discounts, so you do not need to add this validation.