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

StateOfSolace
New Member
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 %}

0 Likes
Jkolinovich
Excursionist
80 12 17

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 you liked my answer, like it
If I solved your question, click Accept as a solution
JKolinovich | JkoDesigns | for custom solutions contact me
StateOfSolace
New Member
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 %}
0 Likes
Jkolinovich
Excursionist
80 12 17

@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 you liked my answer, like it
If I solved your question, click Accept as a solution
JKolinovich | JkoDesigns | for custom solutions contact me
0 Likes
Jkolinovich
Excursionist
80 12 17

@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 you liked my answer, like it
If I solved your question, click Accept as a solution
JKolinovich | JkoDesigns | for custom solutions contact me
0 Likes
Jkolinovich
Excursionist
80 12 17

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

If you liked my answer, like it
If I solved your question, click Accept as a solution
JKolinovich | JkoDesigns | for custom solutions contact me
0 Likes