Add free gift to cart (WITHOUT APP)

New Member
1 0 0

why would you tell us you found a way to do it without sharing how? Please share 

4 0 3

If you just need to add the item to the cart, this should be possible with the Cart API and some JavaScript and Liquid. Haven't fully tested, but the code below should work - you just need to replace the variant ID variables with the correct IDs. The code checks to see if the cart contains the qualifying product, the free product, and then if the first condition is true and the second false, will add quantity 1 to the cart. This code can be inserted at the bottom of the theme.liquid file before the closing body tag (</body>) or stored in a snippet and rendered in that place. 

The discount can be created as an automatic discount.


  window.onload = function(){
    let cartContainsFreeProduct = false;
    let cartContainsQualifyingProduct = false;
    const qualifyingProductVariantId = ***ENTER VARIANT ID OF PRODUCT THAT QUALIFIES FOR FREE PRODUCT***; 
    const freeProductVariantId = ***ENTER VARIANT ID OF THE FREE PRODUCT***;
    {% for item in cart.items %}
      if({{ }} === freeProductVariantId){
        cartContainsFreeProduct = true; 
      if({{ }} === qualifyingProductVariantId){
         cartContainsQualifyingProduct = true;
    {% endfor %}
//  If cart contains qualifying product and doesn't already contain free product, add qty 1 of free product
    if(cartContainsQualifyingProduct && cartContainsFreeProduct === false) {
     '/cart/add.json', { quantity: 1, id: freeProductVariantId })
      .done(function() {window.location.reload()})    





New Member
1 0 3

This should absolutely be a normal Shopify feature. It is confusing and clunky to require customers to add both items to get the BOGO, and should not require additional coding. Most of the bundle apps suck, require more coding, and some disable normal Shopify functions (the last time we did a bundle promo abandoned cart emails wouldn't send).

New Member
1 0 0

Not getting this script to work on my end. I have a discount setup to auto make my product free on orders over $50. So i just need to auto add the product to cart. Preferably auto add the product to the cart if the cart is $50 or more, and remove it if the cart is under that.