Show a message when a specific item count in cart shopify is reached

Hello,

I have a problem with my cart. On my site I sell beers and wine. For beers I would like to replace my checkout button in the cart with a text ad when the total number of beers in the cart is not equal to 6, 12, 18 or 24.

The beers on my site have the tag “beer”

So for the moment i added this code on the “main-cart-footer.liquid” file

I need your help to find how to write the function " When item in cart with product tag isn’t 6, 12, 18 or 24, show the message"

So for the moment i added this code on the “main-cart-footer.liquid” file

{% assign isTagAvailable = false %}
{% for item in cart.items %}
{% if item.product.tags contains ‘beer’ (missing part) %}
{% assign isTagAvailable = true %}
{% endif %}
{% endfor %}
{% if isTagAvailable %}

we do not ship less than 6 beers

{% endif %}

thanks in advance, !

The website : https://epi-curieux.com/
the code : hc1994

Hi @Ramijja Please visit the following dummy store I have made logic to your problem. add any product in the cart then see the cart page and try to change the quantity and see checkout button changes.

https://best-jewlery-box.myshopify.com/cart

password: anc

Hello, Thanks for your answer.
But what happened if the client add for example 2 beers and 4 wine ?

The button should be still disabled until there are 6 beers in the cart

this will only affect products with beer tags. If there are 2 beers and 4 wines, the button will be disabled. if there are 6 beers and 1 wine, the button will be active.

you can control everything.

Then it’s perfect !
And is it possible to say:
disable checkout button when the number of product with tag beer in cart isnt = to 6, 12, 18 or 24 ?

yes any logic can be applied to quantity

Thanks man you are the boss ! Appreciate !

How do you want these changes to be done?

i would like to add it on my shop by myself

ok, that’s great, really appreciate it.

I will add two products with tags beer and wine to the dummy store. when you like it I will send the step-by-step video guide with the code to implement it in your store.

Thanks a lot !

You want to activate the checkout button when the beer items quantity is equal to 6, 12, 18, or 24.

if items are 9 or 15, what to do?

also if there are two products of beer tag and their quantity sum equals to 6 or 12 or 18 or 24, then what to do?

I have 10 products with a tag “beer” in my shop.

If in my cart i have:
1 white beer (tag beer)

5 blond beer (tag beer)
9 wine (tag wine)

I have 15 product in my cart but 6 of them have the beer tag : enable checkout button

If in my cart i have:
4 white beer (tag beer)

5 blond beer (tag beer)
3 wine (tag wine)

I have 12 product in my cart but 9 of them have the beer tag : disable checkout button

If there are 6, 12, 18 or 24 beer tag in the cart (no matter how many ohers products they are in the cart), enable the check out button

Hi @Ramijja

here is a dummy test store

https://best-jewlery-box.myshopify.com/cart

password: anc

Here is the link to two products with bear tags, I just borrowed two pictures from your store.

https://best-jewlery-box.myshopify.com/products/beer1

https://best-jewlery-box.myshopify.com/products/beer2

please add these two products to the cart with other product and play around with the quantity to check your desired functionality and let me know.

Sorry for late reply,
Thanks a lot for your help, i finally have a working solution :slightly_smiling_face:

epi-curieux.com/

Hi @Ahsan_ANC I was wondering if you could help me embed the same logic in my cart?