Personalized checkout and custom promotions with Shopify Scripts
I have this piece of code that works great, but I need it to skip this discount if a coupon code worth $50 or more is used at checkout. I also need it to not break the rest of the cart scripting which it does with nearly every attempt I've made.
Here is the current script portion:
DISCOUNT_AMOUNT = 5
if (!Input.cart.customer.nil? && Input.cart.customer.accepts_marketing?)
Input.cart.line_items.each do |line_item|
line_item.change_line_price(line_item.line_price * (1.0 - (DISCOUNT_AMOUNT / 100.0)), message: "#{DISCOUNT_AMOUNT}% off for subscribing to our newsletter!")
end
end
Can anyone point me in the right direction?
Hey Community 👋 Did you know that March 15th is National Everything You Think Is W...
By JasonH Apr 1, 2025Discover how to increase the efficiency of commerce operations with Shopify Academy's l...
By Jacqui Mar 26, 2025Shopify and our financial partners regularly review and update verification requiremen...
By Jacqui Mar 14, 2025