Personalized checkout and custom promotions with Shopify Scripts
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?
Learn these 5 things I had to learn the hard way with starting and running my own business
By Kitana Jan 27, 2023Would you love to unleash the unbridled power of the Google Shopping Channel into your sho...
By Gabe Jan 6, 2023How can you turn a hobby into a career? That’s what Emmanuel did while working as a wa...
By Skye Dec 30, 2022