Hide checkout button if specific tags on cart

Hello @LitExtension

I try to look for some suggestions but have no luck, maybe you can help me out.

I tried to disable the checkout button on cart if 2 specific product tags added to the cart, is this possible,

let’s say a customer added a product with tags ‘new-arrivals’ and ‘open-stock’ then checkout button disable.

Hello @albertloekito ,

Greetings from the Store Watchers Support Team! Happy to help you today.

Go to Online Store → Actions → Edit code.

In your cart template, wrap your checkout button code using the condition below.

{% unless customer.tags contains 'new-arrivals' or customer.tags contains 'open-stock' %}
//you checkout button code here
{% endunless %}

Let me know if need further assistance

Regards,
Store Watchers Support Team

Hello @StoreWatchers

Thank you for your help, I copied your code (I change the customer to product.tags since I need by product tags) below but is not working the checkout button still visible

{% unless product.tags contains ‘new-arrivals’ or product.tags contains ‘open-stock’ %}
<button type=“submit” id=“checkout” class=“cart__checkout-button button” name=“checkout”{% if cart == empty %} disabled{% endif %} form=“cart”>
{{ ‘sections.cart.checkout’ | t }}
{% endunless %}

Hello @StoreWatchers

Just to make it clear what I need is if the customer adds any items containing tags

‘new-arrivals’ and ‘open-stock’ hide the checkout button

otherwise show the checkout button and I’m using Dawn Theme. Thank you

Hello @albertloekito ,

Greetings from the Store Watchers Support Team! Happy to help you today.

Please update the code as below:

{% assign isTag = false %}

{% for item in cart.items %}
{% if item.product.tags contains 'new-arrivals' or item.product.tags contains 'open-stock' %}
{% assign isTag = true %}
{% endif %}
{% endfor %}

{% unless isTag %}
//your checkout button code here
{% endunless %}

Let me know if need further assistance

Regards,
Store Watchers Support Team

Hello @StoreWatchers

Thank you for the code, however still not working correctly,

  • If I add item A (w/ tag new-arrivals) and Item B (w/ tag open-stock) - Works ok (checkout disabled)

  • If I add item A (w/ tag new-arrivals) only - Works ok (checkout enabled)

  • If I add Item B (w/ tag open-stock) only - Not working (checkout disabled) it should be enabled

Hello @StoreWatchers

Update, please see the below scenario

  • If I add item A (w/ tag new-arrivals) and Item B (w/ tag open-stock) - Works ok (checkout disabled)

  • If I add item A (w/ tag new-arrivals) ONLY - Not working (checkout disabled) it should be enabled

  • If I add Item B (w/ tag open-stock) ONLY - Not working (checkout disabled) it should be enabled

Hello @StoreWatchers

No Worries, I found the solution already, thank you for all your help.

Hello @albertloekito I would be very interested in the solution you found, because I am looking to do the same thing. Can you share what you discovered? Thanks in advance.