Block discount code on top of shopify script

Highlighted
Tourist
5 0 2

Afternoon, i've seen similar questions but i'm really struggling on the implementation.

 

I have experience with HTML, CSS & Javascript but not Ruby so it's rather confusing.

The script for the discount is contained in this link: https://www.pastiebin.com/5cdaa1632079b

 

I have looked and you can indeed reject discount codes using scripts, this is the code i found

 

Input.cart.discount_code.reject({message: "Save 10% with our Sets"})

 

However i cannot place this code inside my existing script without it erroring, can anyone point me in the right direction?

 

 

 

 

 

 

0 Likes
Highlighted
Tourist
5 0 2

I worked this out myself, here is the correct code that needs to be added. 

 

if Input.cart.discount_code
  Input.cart.discount_code.reject(
    message: "Discount codes cannot be redeemed with our Sets"
  )
end

The placement of the code is below, add the snippet just above the CAMPAIGNS = [ section and it works.

 

screenie.png

Highlighted
New Member
1 0 0

Thanks for the code. This works on my site too. Also is there any chance we could make this only works on the items with the discount. If the cart was mixed with discounted item and one without the discount, it rejects discount from all item even thought there's item without the discount.

0 Likes