How to remove an automatic discount when a manual discount is entered?
If you want the automatic discount applied by a Shopify Script to be removed when a manual discount code is entered in checkout, you can use the following script:
This allows you to avoid double stacking of discounts.
Input.cart.line_items.each do |line_item|
if !Input.cart.discount_code
if line_item.properties.has_key?("__upsell_id")
line_item.change_line_price(line_item.line_price * 0.7 message: "30% OFF")
end
end
end
Output.cart = Input.cart
This allows you to avoid double stacking of discounts.
Updated on: 21/11/2023
Thank you!