How to hide price and Buy button for non b2b user for a specific collection.

mpatsia
Shopify Partner
79 0 7

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

Replies 3 (3)

azamgill
Shopify Partner
312 46 68

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' %}
    <p>Contact us for pricing</p>
  {% endif %}
{% endif %}

 

Thanks

Azam Gill
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- Encourage me ❤️

Come and visit us at Wbify
mpatsia
Shopify Partner
79 0 7

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.

azamgill
Shopify Partner
312 46 68

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' %}
    <p>Contact us for pricing</p>
  {% endif %}
{% endif %}
Azam Gill
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- Encourage me ❤️

Come and visit us at Wbify