I want to remove the add to cart button for a particular vendor

StateOfSolace
Visitor
2 0 0

We aren't allowed to sell a certain suppliers products online but still want customers to see what we have in store and sizes available. I had originally created a new product.notavailable template and section a deleted the below code but it doesn't show the sizes out of stock.

I'm thinking the easiest way to do this would be editing the below code so the add to cart button is disabled for this particular vendor but can't work out the correct statement to make it work.

Any help would be appreciated!

 

{% if product.available %}
<button id="AddToCart-{{ section.id }}" type="submit" name="add" class="btn btn--add-to-cart{% if section.settings.enable_payment_button %} btn--secondary-accent{% endif %}">
<span class="btn__text">{{ 'products.product.add_to_cart' | t }}</span>
</button>
{% else %}
<button type="button" class="btn btn--add-to-cart btn--disabled{% if section.settings.enable_payment_button %} btn--secondary-accent{% endif %}" disabled="disabled">
{{ 'products.product.sold_out' | t }}
</button>
{% endif %}
{% if section.settings.enable_payment_button %}
{{ form | payment_button }}
{% endif %}

Replies 12 (12)

Toorbia
Shopify Partner
142 18 33

hi @StateOfSolace 

I am using your same code.
do this validation to hide the button if it is the provider you want to hide.
note: keep in mind upper and lower case

 

 

{% if product.available %}
       {% unless product.vendor == 'JkoDesignsr' %}
             <button id="AddToCart-{{ section.id }}" type="submit" name="add" class="btn btn--add-to-cart{% if 
                 section.settings.enable_payment_button %} btn--secondary-accent{% endif %}">
               <span class="btn__text">{{ 'products.product.add_to_cart' | t }}</span>
            </button>
      {% endunless %}
{% else %}
<button type="button" class="btn btn--add-to-cart btn--disabled{% if section.settings.enable_payment_button %} btn--secondary-accent{% endif %}" disabled="disabled">
{{ 'products.product.sold_out' | t }}
</button>
{% endif %}
{% if section.settings.enable_payment_button %}
{{ form | payment_button }}
{% endif %}

 

 

 

{% unless product.vendor == 'JkoDesignsr' %}

This code validates if your provider is the one you chose, if it is not, it shows the button

 

 

 

- If I solved your question, click Accept as a solution
-for custom solutions contact me by mail | henrijeair@gmail.com

StateOfSolace
Visitor
2 0 0
This probably isn't the best solution but it seems to be working for me now!
 
 
{% if product.vendor ==  'vendor name' %}
          </p>
 
<p></p>
              <p>We are unable to sell vendor name via our online store, however we can still assist you via a remote shopping experience. Please chat to our friendly team via the chat box, call us on .....</p>
              <p>...</p>
          {% else if product.available %}
              <button id="AddToCart-{{ section.id }}" type="submit" name="add" class="btn btn--add-to-cart{% if section.settings.enable_payment_button %} btn--secondary-accent{% endif %}">
                <span class="btn__text">{{ 'products.product.add_to_cart' | t }}</span>
              </button>
            {% else %}
              <button type="button" class="btn btn--add-to-cart btn--disabled{% if section.settings.enable_payment_button %} btn--secondary-accent{% endif %}" disabled="disabled">
                {{ 'products.product.sold_out' | t }}
              </button>
            {% endif %}
            {% if product.vendor ==  'vendor name' %}
       
        {% else if section.settings.enable_payment_button %}
              {{ form | payment_button }}
            {% endif %}
Toorbia
Shopify Partner
142 18 33

@StateOfSolace 

if it works well, in the publication you did not mention that you wanted to place a text. but that validation works fine.

- If I solved your question, click Accept as a solution
-for custom solutions contact me by mail | henrijeair@gmail.com
Toorbia
Shopify Partner
142 18 33

@StateOfSolace 

it looks better that way

 

{% if product.available %}
       {% if product.vendor == 'NAME OF VENDOR' %}
        <p>   text for customers </p>
      {% else %}
             <button id="AddToCart-{{ section.id }}" type="submit" name="add" class="btn btn--add-to-cart{% if 
                 section.settings.enable_payment_button %} btn--secondary-accent{% endif %}">
               <span class="btn__text">{{ 'products.product.add_to_cart' | t }}</span>
            </button>
      {% endif %}
{% else %}
<button type="button" class="btn btn--add-to-cart btn--disabled{% if section.settings.enable_payment_button %} btn--secondary-accent{% endif %}" disabled="disabled">
{{ 'products.product.sold_out' | t }}
</button>
{% endif %}
{% if section.settings.enable_payment_button %}
{{ form | payment_button }}
{% endif %}

 

 

- If I solved your question, click Accept as a solution
-for custom solutions contact me by mail | henrijeair@gmail.com
Toorbia
Shopify Partner
142 18 33

If you liked my answer, like it
If I solved your question, click Accept as a solution

- If I solved your question, click Accept as a solution
-for custom solutions contact me by mail | henrijeair@gmail.com
Nuffe
Excursionist
15 0 2

Hi!

 

I am looking for the same solution as I have the same problem. I was wondering where you put the code? 🙂 

Toorbia
Shopify Partner
142 18 33

hello @Nuffe 
This part of code can be placed in product-template-liquid, depending on what theme you are using, some themes vary, but most use product-template.
Now look for the part of the code for the add to cart buttons and place it there. Remember to work on a copy before making a major change.
find {{ 'products.product.add_to_cart' | t }}
or {{ form | payment_button }}
and you will find that part of the code..

- If I solved your question, click Accept as a solution
-for custom solutions contact me by mail | henrijeair@gmail.com
Nuffe
Excursionist
15 0 2

Thank you so much for helping! 

I use the Prestige theme. I have these:

Which one is the same as the product.liquid? 🙂

 Skjermbilde 2022-04-01 kl. 02.30.21.png

Toorbia
Shopify Partner
142 18 33

I don't have that theme, check the files

 

Sections / main-product.liquid

 

snippets / product-form.liquid 

snippets / product-item.liquid 

 

- If I solved your question, click Accept as a solution
-for custom solutions contact me by mail | henrijeair@gmail.com
Nuffe
Excursionist
15 0 2

Thank you! Do I need to find the codes you send above in one of these and paste it besides this? 

Nuffe
Excursionist
15 0 2
I have this code, but I do not know where to put it: 
I use the prestige theme:)
 
{% if product.vendor ==  'vendor name' %}
          </p>
 
<p></p>
              <p>We are unable to sell vendor name via our online store, however we can still assist you via a remote shopping experience. Please chat to our friendly team via the chat box, call us on .....</p>
              <p>...</p>
          {% else if product.available %}
              <button id="AddToCart-{{ section.id }}" type="submit" name="add" class="btn btn--add-to-cart{% if section.settings.enable_payment_button %} btn--secondary-accent{% endif %}">
                <span class="btn__text">{{ 'products.product.add_to_cart' | t }}</span>
              </button>
            {% else %}
              <button type="button" class="btn btn--add-to-cart btn--disabled{% if section.settings.enable_payment_button %} btn--secondary-accent{% endif %}" disabled="disabled">
                {{ 'products.product.sold_out' | t }}
              </button>
            {% endif %}
            {% if product.vendor ==  'vendor name' %}
       
        {% else if section.settings.enable_payment_button %}
              {{ form | payment_button }}
            {% endif %}
 
Toorbia
Shopify Partner
142 18 33

find {{ 'products.product.add_to_cart' | t }}
or {{ form | payment_button }}

in each file sections or snippets
and you will find that part of the code..

- If I solved your question, click Accept as a solution
-for custom solutions contact me by mail | henrijeair@gmail.com