Solved

Customize Checkout for Specific Product Tags - Debut Theme

mraza9
Tourist
6 0 0

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' %}

<Checkout>

{% 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' %}

<Checkout>

{% 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' %}

<Checkout>

{% 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.

Accepted Solution (1)
ProfessionalNub
Shopify Partner
101 13 30

This is an accepted solution.

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.PNG2.PNG3.PNG

Need help bro? I got you
Email: martinerceg@outlook.co.nz
- Website Developer

View solution in original post

Replies 8 (8)

ProfessionalNub
Shopify Partner
101 13 30

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' %}

<Checkout>

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

 

You would do

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

<Checkout>

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

 

Hope it helps.

Regards,

Martin

Need help bro? I got you
Email: martinerceg@outlook.co.nz
- Website Developer
Jason
Shopify Expert
11190 225 2282

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.

★ I jump on these forums in my free time to help and share some insights. Not looking to be hired, and not looking for work. http://freakdesign.com.au ★
mraza9
Tourist
6 0 0

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.

mraza9
Tourist
6 0 0

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' %}

<Checkout>

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

and,

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

<Checkout>

{% 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' %}  

<Checkout>

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

 

{% if product.tags contains 'On Sale' %}

<Checkout>

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

Strange!

Have you got any other solution for this?

Best,

MRaza

ProfessionalNub
Shopify Partner
101 13 30

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'.

1.PNG

{% 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.

Need help bro? I got you
Email: martinerceg@outlook.co.nz
- Website Developer
mraza9
Tourist
6 0 0

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

ProfessionalNub
Shopify Partner
101 13 30

This is an accepted solution.

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.PNG2.PNG3.PNG

Need help bro? I got you
Email: martinerceg@outlook.co.nz
- Website Developer
mraza9
Tourist
6 0 0

Martin,

Thank you so much.

This is exactly the solution I was looking for.

Kind Regards,

MRaza