Hello, looking for code for a tiered discount script based on product tag.
If product tag = "A" discount the line item by 25%
If product tag = "E" discount the line item by 20%
Also, is there a way to prevent additional discount codes entered at checkout, to avoid an extra discount on the above?
Hey Mitch - you might be interested in checking out our (paid) application Playwright, that generates Shopify Scripts on demand (including tiered pricing based on tags) and can support discount code rejection: https://playwright.discolabs.com/login.
I think that you don't need to find the product tag to create the discount campaign on your website. Because it is too complicated to remember for you and your customers.
You only need to use Discount Master, this app will help you create the discount campaign without the product tag. You only choose products or collections, all will be worked automatically. It's nice to introduce to you.
Hey, here is some code you can work off of in the script editor. This is for one tag but can be easily changed to work for two.
@percent = Decimal.new(25) / 100.0 Input.cart.line_items.each do |line_item| product = line_item.variant.product next if product.gift_card? next unless product.tags.include?('Coconut') line_discount = line_item.line_price * @percent line_item.change_line_price(line_item.line_price - line_discount, message: "25% Off") end Output.cart = Input.cart
Hi, MitchEFFY. I also think that it's better (faster and easier) to use a special app. As a choice - Bulk Discount Manager. It allows creating discounts or tiered pricing for one product, multiple items or collections. There is a tag option, where you can tag your products and create smart collections which will automatically include products with certain tags.
How it may work for you:
1. You create a collection, for example, "Daily Deals"
2. Set up a discount or tiered pricing for this collection (as a fixed amount or %)
3. Tag the products you want with "Daily Deals"
4. These products are automatically included in the "Daily Deals" collection and applied for its discount.
There is an FAQ how to set it up.