Articles on: Discounts

How to add a discount to an automated upsell using Script Editor

In the AI upsell offer, let the shopper know about the discount by adding it to the upsell visual:




To add a discount to an AI generated upsell, we will add a script to the Script Editor.

Input.cart.line_items.each do |line_item|
if line_item.properties.has_key?("__upsell_id") and line_item.properties["__upsell_id"]
line_item.change_line_price(line_item.line_price * 0.90, message: "Special discount")
end
end
Output.cart = Input.cart


Add the discount you want to apply. (*0.90 = 10% discount). The same discount will apply to all auto recommended products.

Updated on: 17/09/2024

Was this article helpful?

Share your feedback

Cancel

Thank you!