Personalized checkout and custom promotions with Shopify Scripts
How can I tell if a user has entered a shipping or percentage discount? If I try to access Input.cart.discount_code.percentage and they used a shipping code, I get an error. I noticed in the docs Inputs.cart.discount_code returns "CartDiscount::Shipping, CartDiscount::Percentage, etc. " but I can't seem to figure out the proper syntax:
if Input.cart.discount_code == CartDiscount::Shipping
#do something when user enters shipping discount code
end
Did you ever figure this out? I'm struggling with the same thing.
I tried this and seems working,
my_string = Input.cart.discount_code.to_s
if my_string.include? "FixedAmount"
puts "String includes 'FixedAmount'"
end
On our Shopify Expert Marketplace, you can find many trusted third party developers and fr...
By Arno Nov 27, 2023You've downloaded the Search & Discovery app from the Shopify App store, and as you're ...
By Skye Nov 8, 2023The year-end shopping season is just around the corner. Is a flash sale on your radar? Are...
By Jasonh Nov 6, 2023