How to add a discount to an AI generated upsell using Script Editor
In the AI upsell offer, let the shopper know about the discount by adding it to the upsell visual:
![](https://storage.crisp.chat/users/helpdesk/website/abfa0cd47f75e80/screen-shot-2023-05-24-at-1112_1s54qw1.png)
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.90 = 10% discount). The same discount will apply to all auto recommended products.
![](https://storage.crisp.chat/users/helpdesk/website/abfa0cd47f75e80/screen-shot-2023-05-24-at-1112_1s54qw1.png)
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: 23/07/2024
Thank you!