Customize Checkout for Specific Product Tags - Debut Theme

Hi,

I am using the Debut theme. I have two types of products, one with the tag ‘On sale’ and others with the tag ‘Normal’.

I want that if the customers add products with the tag ‘On sale’ checkout is disabled. If they add products with the tag ‘Normal’, or products with both tags, the checkout should proceed as normal.

The following code helps to eliminate checkout for ‘On sale’ items,

{% if product.tags contains ‘Normal’ %}

{% else %}
Not Available
{% endif %}

I tried to use operators (and, or) for including a scenario where checkout is possible with both tags but it isn’t working.

{% if product.tags contains ‘Normal’ or ‘On sale’ %}

{% else %}
Not Available
{% endif %}

The above won’t stop checkout if there’s only ‘On sale’ tag.

{% if product.tags contains ‘Normal’ and ‘On sale’ %}

{% else %}
Not Available
{% endif %}

The above won’t work because the tags are specific to one product and not both.

Any help will be appreciated.

Thanks.

Hey bro

So when it comes to using ‘or’ and ‘and’ you have to do two full conditions, the way you have it set up is it only completes one condition but not the other (technically it does but not how your wanting to do it). So instead of

{% if product.tags contains 'Normal' and 'On sale' %}

You would do

```javascript
{% if product.tags contains 'Normal' and product.tags contains 'On sale' %}

Hope it helps.

Regards,

Martin
1 Like

If this code is being added to the cart page do keep in mind that a customer can head straight to checkout by going to /checkout. This, along with accelerated gateways, might skip your cart based logic.

1 Like

Martin, Thank you for your response.

I tried these two codes when there were both products in the cart,

{% if product.tags contains ‘Normal’ and product.tags contains ‘On sale’ %}

{% else %}
Not Available
{% endif %}

and,

{% if product.tags contains ‘Normal’ or product.tags contains ‘On sale’ %}

{% else %}
Not Available
{% endif %}

In both cases, the result is ‘Not Available’.

Additionally, I also tried this when there is only ‘Normal’ or ‘On Sale’ products in the cart and it still says ‘Not Available’,

{% if product.tags contains ‘Normal’ %}

{% else %}
Not Available
{% endif %}

{% if product.tags contains ‘On Sale’ %}

{% else %}
Not Available
{% endif %}

Strange!

Have you got any other solution for this?

Best,

MRaza

Jason, Thank you for pointing this out.

I have disabled the Add to Cart button for ‘On Sale’ products unless there is a ‘Normal’ product in the cart. Do you think it will solve the issue?

Thanks.

MRaza.

So just doing some quick testing on the cart page, It works when you put item.product.tags instead of product.tags.

Below here asd doesn’t have ‘Normal’ and/or ‘On sale’ tags, but Glasses does indicated with ‘it works’ instead of ‘Not Available’.

{% if item.product.tags contains 'Normal' and item.product.tags contains 'On sale' %}
   it works
{% else %}
   Not Available
{% endif %}

Also to go on what Jason said you could remove the buy now button so customers won’t bypass the cart page. It’s located in theme panel for the product page. Go to the Product pages section then untick show dynamic checkout button and save it.

Thanks, Martin

I successfully made changes following your answer to stop customers from going directly to the checkout page. The other issue is still pending even after using item.product.tags

Let me add a brief explanation of the logic I want to apply,

Checkout conditions (Display ‘Checkout’ button on the Cart page)

  1. If there is a ‘Normal’ product in the cart

  2. If there are multiple products in the cart with at least one ‘Normal’ product

No Checkout condition (Display ‘Not Available’ text replacing Checkout button)

If there is only an ‘On Sale’ product in the cart

I hope it will make things clear and might help you in proposing another solution.

Best,

MRaza

I’ll propose to you a partial solution but I’ll let you figure out on the rest of it. This solution does the first two for checkout conditions but if it doesn’t find it then it prints not available. Furthermore if it has the onsale tag it will not do anything. Your part will be to implement the no checkout condition with onsale tags.

1.PNG

1 Like

Martin,

Thank you so much.

This is exactly the solution I was looking for.

Kind Regards,

MRaza