Articles on: Discounts

How to remove an automatic discount when a manual discount is entered?

Scripts will be sunset on August 28, 2025. We added Functions discounts. To learn how to do add a functions discount:https://help.upsellplus.com/en/article/discounts-shopify-functions-and-shopify-scripts-yj7gwb/

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:

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: 02/04/2025

Was this article helpful?

Share your feedback

Cancel

Thank you!