Add free gift to cart (WITHOUT APP)

Anton11
Visitor
2 0 3

We want to run a promotion where a customer is entitled to a free gift once they spend over a certain amount. When this condition is true, I want to add the free gift item into the customer's cart. How is this possible WITHOUT AN APP?

I appreciate any help, as so far I have not found anything on this. I am a developer so I shoud be ok if pointed in the right direction.

Thanks!

Replies 15 (15)

Dallas
Shopify Staff (Retired)
916 61 211

Hi, there

This is Dallas from the Social Care team here at Shopify. 

For what you are wanting to do an app would be the best option. However, you may be able to add some modifications to the gift wrapping product feature that is shown here.

This allows a product to automatically be added to the cart when another product is added to the cart. It would need a coding adjustment, however, to allow it to automatically add the product based on the cart value. 

If you are comfortable with writing code then you'd want to replace Step 4. in Create a code snippet with a version that will take value into account rather than the item. 

If you are using a Shopify theme then you can even write in to our email support and we can take a look to see if our themes team can get this set up for you. If you are using a third party theme then I suggest reaching out to the Experts. They will be a great option for getting this up and running. You are able to check what your theme is by going to your Theme Customizer (Online Store > Themes > Theme Customizer in your Store Admin). From there you can select Theme Settings and scroll down to the bottom of the sidebar. 

If you would rather just download an app these ones are great options for what you are looking for: 

I hope this helps you out! If you have any other questions please don't hesitate to let me know. We also have 24/7 phone/chat/email support with gurus ready to answer your questions.

Cheers, 
Dallas 

To learn more visit the Shopify Help Center or the Community Blog.

Bunny_Ghatrora
Visitor
1 0 2

Hey Anton! Did you get this to work? I'm looking for the same solution. 

If so, does the customer have to select the free gift option? Or is it automatically applied? 

Sequoyah
Visitor
3 0 0

Hi! Did you find a code to do this? I have been looking for a while now

bumbastic
Explorer
50 1 14
Found a way to do this WITHOUT an app? 🙂
d33d334
Visitor
1 0 0

 


@bumbastic wrote:
Found a way to do this WITHOUT an app? 🙂


Can you share the info please?

Rayo
Visitor
2 0 0

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

RichC
Shopify Partner
7 0 10

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.

 

<script>
  
  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({{ item.id }} === freeProductVariantId){
        cartContainsFreeProduct = true; 
      }
      if({{ item.id }} === 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) {
        
      jQuery.post('/cart/add.json', { quantity: 1, id: freeProductVariantId })
      .done(function() {window.location.reload()})    
        
     } 
  }
  
</script>

 

 

 

 

mredmonWF
Visitor
1 0 9

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).

angelinaswan
Excursionist
12 0 26

I absolutely agree. Coming over from many years at BigCommerce, I'm frustrated with Shopify's lack of very basic features like this one. I have about a dozen (probably more) apps now and have about half the function that I had at BC on the most basic plan. 

BochExotics
Visitor
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.

Simon2285
Tourist
3 0 0

Hi all,

 

a slight work-around to this problem is to set-up a product variant on the product page. I used this in a promo recently where we would give away a 'gift item' at a high discounted price (say $10) with the purchase of another item. 

 

Using this method the customer can select this variant on the product page (essentially creating a type of bundle).

 

Pros:

It removes the steps of having to create an on-page link to another page and hoping the customer adds the promotional item their cart.

 

Cons:

If you're running this type of promo across a product category (multiple products) you have to set up the variant across all products used in a promotion.

 

Shopfiy should definitely be creating a simple solution for this common type of promotional condition, without the need for terrible UX.

 

You hear that Shopify!

 

MACRORY
Excursionist
32 2 7

An easy way is create automatic discount and with 'Buy X get Y' over a specific amount. Then select the free gift in Discount Panel. 

bumbastic
Explorer
50 1 14
yeeah... but then customers have to add gift theirselves.
bredowmax
Shopify Partner
86 1 126
I would love, too, if the customer didn’t have to add their free gift to the cart themselves. I’ve seen this request numerous times in the forum
Anna92
Visitor
1 0 1

Hi everyone!

I'm searching for a way to gift my customers with a product once they add another specific product to cart!

I would like it will be automatically, without the action of adding into the cart the gift product.

It seems to be a popular topic, but I can't find anywhere the perfect solution for that!

Can anyone try to help me with some tips?

Thanks 🙏