Liquid, JavaScript, themes, sales channels
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 %}
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 it works well, in the publication you did not mention that you wanted to place a text. but that validation works fine.
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
Hi!
I am looking for the same solution as I have the same problem. I was wondering where you put the code? 🙂
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..
Thank you so much for helping!
I use the Prestige theme. I have these:
Which one is the same as the product.liquid? 🙂
I don't have that theme, check the files
Sections / main-product.liquid
snippets / product-form.liquid
snippets / product-item.liquid
Thank you! Do I need to find the codes you send above in one of these and paste it besides this?
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..
Portrait of Stephen positioned next to an image of planet Earth, with the Stephen's World ...
By JasonH Mar 18, 2024Digital marketers and app developers have tracked activity in apps and websites for yea...
By Ollie Mar 13, 2024February was an exciting month with Shopify Editions, informative webinars, and more! F...
By JasonH Mar 7, 2024