add product tag to a shopify discount script

girlmeetschic
Visitor
2 0 0

Hi There, thanks in advance for help.  I have a working shopify discount script but need to add a product tag(s) to it and cannot seem to find a solution that works.  Here is the script:

DISCOUNT_AMOUNT = 40

if (Input.cart.line_items.size > 1)
line_item = Input.cart.line_items.sort_by { |line_item| line_item.variant.price }.last
if line_item.quantity > 1
line_item = line_item.split(take: 1)
Input.cart.line_items << line_item
end
line_item.change_line_price(line_item.line_price * (1.0 - (DISCOUNT_AMOUNT / 100.0)), message: "#{DISCOUNT_AMOUNT}% off!")
end

Output.cart = Input.cart

 

I need this to reflect products with specific tag.  If qualified item(s) is in the cart and it is the highest priced item, discount will be applied to that item.

Advise?

 

Replies 0 (0)