Articles on: Checkout

How to automatically add a Free Gift with Purchase to the cart

Create a new offer. Select ‘Checkout Page’.
The product you set up will be added automatically to the cart once the shoppers navigates to the checkout.

Scroll down to the Smart Rule section
Tick the ‘Automatically add to cart when conditions are met’ checkbox. 



Make the product free
To make it free, we will set the discount price at 0% of the original price.




Configure the discount with Shopify Scripts

Go to the Shopify Scripts app and use the offer ID to target an offer with a 100% discount.

In the UpsellPlus app, every offer has an offer ID. It is displayed at the top, just under the internal name.



In the Script Editor, you can add the following script to do so:

Input.cart.line_items.each do |line_item|
if line_item.properties.has_key?("__upsell_id") and line_item.properties["__upsell_id"].include? "e766cbff-060d-4ed7-9797-ccb9d2bdcf1a"
line_item.change_line_price(line_item.line_price * 0.0, message: "Free Gift!")
end
end
Output.cart = Input.cart


Note that you can customize the discount message. Here it says 'Free Gift'

Updated on: 22/02/2024

Was this article helpful?

Share your feedback

Cancel

Thank you!