How To Add Free Product Automatically To Cart?

Hello,

I am using prestige theme.

I want to add some free products to cart automatically.

When the cart amount of any user reaches a certain limit then we want to add a free product automatically to their carts. I want to create two offers

When the cart amount of any user is greater than 10,000 and less than 15,000 then we want to give a free product and

When the cart amount of any user is greater than 15,000 then want to give another free product.

I have tried a lot and also used some apps but couldn’t find any solution?

Please try to help me as soon as possible…

We do this using the javascript ajax API, here’s the documentation for cart: https://shopify.dev/api/ajax/reference/cart

The typical approach with that is:

  1. Create a script that checks the cart value to see if it’s in the range of your specifications

  2. If it’s in range, add that product to cart (that documentation will show you how) and show a message to let the user know it’s there (Example you can pop a message near the top, with a color that stands out and calls the user to go to their cart to see the free product).

  3. Add an event listener to trigger the script when you want (probably after adding a product to the cart, unless your users always go to cart page before checking out, then you could add the check on cart page)

  4. You probably want to create a script to remove the free product as well if the cart sizes diminishes under the threshold.

If you need help with part of this or want it done for you feel free to reach out to my team at speedboostr.com/contact, we’re a team of Shopify developers that do performance optimization, custom features, theme builds, and apps.