Auto discount for accepting Marketing Emails

R_Reno
Shopify Partner
14 0 2

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?

Replies 0 (0)