Disabling Buy Button based on customer tags

Hello,

In the store, I have linked the CRM on line app which connects the Line App of customer. Now I want the customers to be able to place the order only if they have been connected to Line. Basically when they connect to Line, a customer tag is automatically added to the customer. My question is, is there any way where we can disable the Add to Cart/Buy button based on customer tags? Same as, the add to cart should be enabled only to customers with a specified tag. If there is any method to do the same, please let me know.

Thanks in advance.

Hi @megharose , do you want to disable button or hide it?
If you want to hide it, here is an example:

{% if customer.tags contains "someTAG" %}
//Code for buttons
{% else %}
//Something else
{% endif %}

if this doesn’t work, try looping:

{% for tag in customer.tags %}
 {% if tag == "someTAG" %}
   //code for buttons
{% else %}
 //something else
 {% endif %}
{% endfor %}

if you find my answers helpful, please mark resolved or like.

Thanks!

In what area of “edit code” do we place this?