Line item warning but disappears when item is added

Solved
UK_Aspire_Vendo
Excursionist
31 0 3

Hi guys,

I'm struggling with a particular line of code that I can't quite get to work.

We sell a number of products which (ideally) need to be purchased with something else for it to work.

I've inserted a few lines of code into our cart, which show up as expected, however I want the 'warnings' to go away when the required item is added to the cart.

I can't seem to get the code to recognise when the item is added, to remove the warnings.

Here's the code I've installed so far, please could one of you lovely people help me out?

 

(for reference, the line that shows line item sku 'L-NN-NS-18' is the item that when it's added, all 'please note' warnings will disappear.

 

{% if line_item.sku contains 'L-NN-NS-18' %}
{% break %}
{%- if line_item.title contains '50ml' %}
<font color="red"><b>PLEASE NOTE</b></br>You will need to purchase 1x 18mg Nic Shot to make this liquid 3mg</font>
{% else %}
{%- if line_item.title contains '80ml' %}
<font color="red"><b>PLEASE NOTE</b></br>You will need to purchase 2x 18mg Nic Shot to make this liquid 3mg</font>
{% else %}
{%- if line_item.title contains '100ml' %}
<font color="red"><b>PLEASE NOTE</b></br>You will need to purchase 2x 18mg Nic Shot to make this liquid 3mg</font>
{% else %}
{%- if line_item.title contains '200ml' %}
<font color="red"><b>PLEASE NOTE</b></br>You will need to purchase 4x 18mg Nic Shot to make this liquid 3mg</font>



{% endif %}
{% endif %}
{% endif %}
{% endif %}
{% endif %}

0 Likes
Jivan_Suhagiya
Shopify Partner
458 62 95

Edit: I made mistake

 

 

If helpful then please Like and Accept Solution.
Email: suhagiyajivan1992@gmail.com
Skype: jivan.suhagiya
First kind of Checkout Reminder APP: https://apps.shopify.com/checkout-reminder
0 Likes
UK_Aspire_Vendo
Excursionist
31 0 3

Solid effort mate, but unfortunately it didn't work - when I add the sku'd item in question, (alongside the 50ml, 80ml, 100ml or 200ml items) the red warning message remains

UK_Aspire_Vendo_0-1601981255338.png

 

0 Likes
Jivan_Suhagiya
Shopify Partner
458 62 95

I hope this will work

{% assign all_items_skus = '' %}
{% for item in cart.items %}
  {% assign item_sku = item.sku | append: ',' %}
  {{ all_items_skus | append: item_sku }}
{% endfor %}

{% unless all_items_skus contains 'L-NN-NS-18' %}

{%- if line_item.title contains '50ml' %}
<font color="red"><b>PLEASE NOTE</b></br>You will need to purchase 1x 18mg Nic Shot to make this liquid 3mg</font>
{% elsif line_item.title contains '80ml' %}
<font color="red"><b>PLEASE NOTE</b></br>You will need to purchase 2x 18mg Nic Shot to make this liquid 3mg</font>
{% elsif line_item.title contains '100ml' %}
<font color="red"><b>PLEASE NOTE</b></br>You will need to purchase 2x 18mg Nic Shot to make this liquid 3mg</font>
{% elsif line_item.title contains '200ml' %}
<font color="red"><b>PLEASE NOTE</b></br>You will need to purchase 4x 18mg Nic Shot to make this liquid 3mg</font>

{% endif %}
{% endunless %}


Please define first 5 lines above the cart.items forloop 

If helpful then please Like and Accept Solution.
Email: suhagiyajivan1992@gmail.com
Skype: jivan.suhagiya
First kind of Checkout Reminder APP: https://apps.shopify.com/checkout-reminder
0 Likes
UK_Aspire_Vendo
Excursionist
31 0 3

Hey mate,

That looks fantastic, however could you expand on what I need to do with the first 5 lines?

Alternatively, I only picked up on the SKU for the non-warning product because I felt it would be easier. We could go by product title if it makes it easier?

The product name is "Nic Nic 10ml 18mg Nic Shot"

Cheers buddy

0 Likes
Jivan_Suhagiya
Shopify Partner
458 62 95

SKU is fine, you can put first 5 lines in top of file(cart.liquid or cart-template.liquid whatever you have)

If helpful then please Like and Accept Solution.
Email: suhagiyajivan1992@gmail.com
Skype: jivan.suhagiya
First kind of Checkout Reminder APP: https://apps.shopify.com/checkout-reminder
0 Likes
UK_Aspire_Vendo
Excursionist
31 0 3

I get you, but unfortunately all that does is display SKUs for what's in the cart at the top of the page, and the warning note remains when the mentioned SKU is in the cart

0 Likes
Jivan_Suhagiya
Shopify Partner
458 62 95

do you have skype for quicker chat? 

If helpful then please Like and Accept Solution.
Email: suhagiyajivan1992@gmail.com
Skype: jivan.suhagiya
First kind of Checkout Reminder APP: https://apps.shopify.com/checkout-reminder
0 Likes
UK_Aspire_Vendo
Excursionist
31 0 3

unfortunately not - however feel free to email me at Dave@ukaspirevendor.co.uk 

0 Likes
Jivan_Suhagiya
Shopify Partner
458 62 95

This is an accepted solution.

lol, again I made mistake
replace first 5 lines with this
{% assign all_items_skus = '' %}
{% for item in cart.items %}
{% assign item_sku = item.sku | append: ',' %}
{% assign all_items_skus = all_items_skus | append: item_sku %}
{% endfor %}

If helpful then please Like and Accept Solution.
Email: suhagiyajivan1992@gmail.com
Skype: jivan.suhagiya
First kind of Checkout Reminder APP: https://apps.shopify.com/checkout-reminder