How to Automatically Add a product to cart when certain products are selected

Highlighted
New Member
2 0 0

Hello,

I need help with some codes i'm working with. I am trying to write a code where when any product containing tag name "byob" is selected, the system will automatically add a one time flat rate of say $30 to the cart that cannot be removed by a customer. 

Here's what I've done so far:

1.  I created a product called "Gift wrapping"  

2. in SNIPPET Directory, I created a new Snippet called: “Gift Wrapping” and added the following codes

{% if item.tag == 'byob' %}
{% include 'cart-add-on-1' %}

{% endif %}

 

3. In SECTION Directory: I clicked cart-template.liquid  then Searched for “</form> and added above it:

{% render 'gift-wrapping' %}

 

4. In LAYOUT Directory: I searched for </head> tag and above it pasted the following code:

{{ '//ajax.googleapis.com/ajax/libs/jquery/2.2.3/jquery.min.js' | script_tag }}

 

But it isn't working. I'm not sure what i'm missing but will greatly appreciate it if anyone can help me out.

Thanks in advance!

0 Likes