How to add a discount to an automated upsell using Script Editor
In the ShopBrain upsell offer, add a compare at price to the recommended products.
To add a discount to an AI generated upsell, we will add a script to the Script Editor.
Add the discount you want to apply. (*0.80 = 20% discount). The same discount will apply to all auto recommended products of this offer.
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.80 = 20% discount). The same discount will apply to all auto recommended products of this offer.
Updated on: 04/12/2024
Thank you!