This is a good example https://help.shopify.com/en/manual/checkout-settings/script-editor/examples/line-item-scripts#tiered-product-discount-by-quantity
But I need it to work only if you enter code herechoose the same variant. You cant mix and match. The product has multiple variants but I only want the discount to apply if the product is in the same variant group.
discount +10 same products
- Example 1 correct
- Phone / variant Black x10 = discount
- phone / variant Red x5 = NO discount
- Example 2 incorrect
- Phone / variant Black x5 = discount
- phone / variant Red x5 = discount
Discount applied because total is 10 but its incorrect because the variant is not the same
Thanks for the help.
Not sure if I understand the question but this should be a good start.
We just check line by line if it's more than
min_quantity
we apply the discount.If you want to apply the discount only once you can just put a
return
inside theif
This will not work if you have discounts already applied to a subset of items of the same variant... line items are separated by sku and price, so for that you would need something more complex. But I was not sure you were interested in that case.