My custom security liquid code suddenly failed the last week of April. I contacted customer service to find out what changed on their end to break it, and got no reply. Can someone here give me a hint?
So here’s what my code does … In my myshopify store, I disabled the Add to Cart button (greyed it out) on product pages based on customer tag, so that only logged-in retailers can purchase certain products (those in the Dropship and Restock collections).
To do that, I implemented the liquid code below, and it worked perfectly as of Feb 2. But at the end of April I started getting reports that the Add to Cart buttons in those restricted collections are suddenly greyed out for logged-in retailers who should have access to them, and products NOT in those collections (no restrictions) are wrongly greyed out for everyone (even not-logged-in non-retail visitors should have access to those). So I’ve had to disable the custom code.
Here’s where the custom code is located … it’s in the Shopify Section file called product-template.liquid in this spot (line 182):
And here's the code in its entirety…
```markup
{% comment %} Start Michelle's security mod {% endcomment %}
{% comment %} Disable Add to Cart button if they're not logged in {% endcomment %}
{% unless customer %}
disabled="disabled"
{% endunless %}
{% comment %} Disable Add to Cart button if 1) the product is in the Dropship collection 2) They're logged in but NOT tagged as a retailer {% endcomment %}
{% for collection in product.collections %}
{% if collection.title == 'Dropship Products' %}
{% if customer %}
{% unless customer.tags contains Retailer %}
disabled="disabled"
{% endunless %}
{% endif %}
{% endif %}
{% endfor %}
{% comment %} Disable Add to Cart button if 1) the product is in the Restock collection 2) They're logged in but NOT tagged as a retailer {% endcomment %}
{% for collection in product.collections %}
{% if collection.title == 'Restock Products' %}
{% if customer %}
{% unless customer.tags contains Retailer %}
disabled="disabled"
{% endunless %}
{% endif %}
{% endif %}
{% endfor %}
{% comment %} End Michelle's security mod {% endcomment %}
My code is based on info found in this article: https://community.shopify.com/c/technical-q-a/how-can-i-make-only-certain-tagged-customers-able-to-order-a/m-p/803417/highlight/true
Any help would be much appreciated!