Remove Add to Cart button from a product with a vendor code?

Hi all,

We need to temporarily stop orders coming in for products under a certain vendor code while we switch suppliers. Is it possible to remove the buy button from all products with a certain vendor code?

Hello @aponton ,

Wrap the atc butoon with this condition

{% if product.vendor == "vendor-name" %}
  // Your atc code goes here
{% endif %}

Regards
Guleria

There are several options. Depending on your theme.

If your theme code is already modified, then you can follow the @Guleria advise, however, you’d need to use unless:

{% unless product.vendor == "vendor-name" %}
  // Your atc code goes here
{% endunless %}

Or,

You can create an alternate product page template, hide/disable “Buy buttons” there and assign it to these products.

Or, you can use CSS in “Custom liquid” section to simply hide cart buttons (no theme code edits):

(CSS rule here is for Dawn)

{% if product.vendor == "the-one" %}
 
{% endif %}

However, this would may prevent your orders for these from coming.

Reliable options would be to either zero the inventory or unpublishing these products.

Hi @aponton ,

Wrap your Add to Cart form in a condition:

{% unless product.vendor == "YourVendor" %}
  {% form 'product', product %}
    <!-- Add to cart button -->
  {% endform %}
{% else %}
  <p>Unavailable while we switch suppliers.</p>
{% endunless %}

Which theme are you using @aponton

Yes you can achieve this in Shopify by hiding or disabling “Buy/Add to cart” button for all products with a specific vendor code. This doesn’t requires manually editing each product. You can handle it via liquid.
Before moving further you must know the exact vendor name as defined in the product settings. After that you need to Edit the code.
Go to Online Store >> Themes >> Edit code
In the Edit Code search for product-template.liquid section. Or it maybe a product.liquid section. It’s vary on the theme that you currently using.
No you need to wrap the Buy button with a condition.
Initial the Buy button should like like this:

<button type="submit" name="add" class="product-form__submit">{{ general.buttons.atc_button 
 t }}</button>

Now replace it with the condition based code:

{% if product.vendor != "VENDOR_CODE" %}
    <button type="submit" name="add" class="product-form__submit">Add to cart</button>
{% else %}
    <p class="text-red-600">Currently unavailable due to supplier change.</p>
{% endif %}

replace the vendor code with the actual code.
I hope this could helps you. If this was helpful then don’t forget to like it.