Solved

Disabling Buy Button based on customer tags

megharose
Tourist
6 0 1

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.

Accepted Solution (1)

MarinaPetrovic
Shopify Partner
559 124 182

This is an accepted solution.

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. 

M.Petrovic | Shopify Developer
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution

View solution in original post

Replies 3 (3)

MarinaPetrovic
Shopify Partner
559 124 182

This is an accepted solution.

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. 

M.Petrovic | Shopify Developer
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
megharose
Tourist
6 0 1

Thanks!

 

CoastalGlowSunl
Tourist
4 0 1

In what area of "edit code" do we place this?