Greetings, I have only one collection of products that are only for professionals and so I want to hide the price and the Buy button of those products but only for the 99% of the people, the b2b customers can normally see the price and Buy button when they are logged in. I have set those products with a product type of “B2B” and the rest of the products have a product type of “B2C” if this helps.
Thanks in advance
Hey @mpatsia ,
I am not sure about your theme but you can try this.
Open the product.liquid or product-template.liquid file in your theme, and add the following code:
{% if customer %}
{% comment %} Customer is logged in, show price and buy button {% endcomment %}
{{ content_for_header }}
{% else %}
{% comment %} Customer is not logged in, hide price and buy button for B2C products {% endcomment %}
{% if product.type == 'B2C' %}
Contact us for pricing
{% endif %}
{% endif %}
Thanks
1 Like
Hello Azamgill and thanks for the replay. This will hide the product price for all products but I have those products inside one only collection that I want to hide it.
Please try this.
{% if customer %}
{% comment %} Customer is logged in, show price and buy button {% endcomment %}
{{ content_for_header }}
{% else %}
{% comment %} Customer is not logged in, hide price and buy button for B2C products {% endcomment %}
{% if product.type == 'B2C' and product.collections contains 'YourSpecificCollectionHandle' %}
Contact us for pricing
{% endif %}
{% endif %}
1 Like