How can I display stock levels to logged-in b2b customers only?

Solved

How can I display stock levels to logged-in b2b customers only?

MaartjeS
Tourist
10 0 6

Hi!

 

Currently I am working on a website for selling to b2c and b2b customers. After the b2b customers login, they will see their purchase price (I already found an app for that), but I would also like to show the stock levels to the b2b customers. If I add this option to the theme, then it will also be visible for the b2c customers, so this is not an option.

 

So, my question is: is there a way to show to logged in b2b customers only the available stock levels on the product page? Maybe to show it to customers with a special customer tag?

 

I hope someone can help me out. The theme that I am using is Dawn.

 

Please let me know if you need more info.

Accepted Solution (1)
PaulMartin
Shopify Partner
251 39 72

This is an accepted solution.

Yes, there we go. Okay, here is an updated code:

{% if customer.tags contains "b2b" %}
show some stuff for b2b customer
{% endif %}
Open to help people out, just email me here or tag me by using "@" when posting your comment

View solution in original post

Replies 7 (7)

PaulMartin
Shopify Partner
251 39 72

There is a way to show stuff only to B2B customers. If you use the code below, it returns either true or false. 

{{ customer.b2b? }}

 Then you can use that to build something like:

{% if customer.b2b? %}
show some stuff for b2b customer
{% endif %}

Liquid objects (shopify.dev) 

Open to help people out, just email me here or tag me by using "@" when posting your comment
MaartjeS
Tourist
10 0 6

Thank you for your quick reply! Is this B2B function not only available for Shopify Plus members? I don't have Shopify Plus.

PaulMartin
Shopify Partner
251 39 72

If that is the case, how are you differentiating the b2c and the b2b customers?

Open to help people out, just email me here or tag me by using "@" when posting your comment
MaartjeS
Tourist
10 0 6

With customer tags. So I thought maybe that can be used in the coding as well.

PaulMartin
Shopify Partner
251 39 72

This is an accepted solution.

Yes, there we go. Okay, here is an updated code:

{% if customer.tags contains "b2b" %}
show some stuff for b2b customer
{% endif %}
Open to help people out, just email me here or tag me by using "@" when posting your comment
MaartjeS
Tourist
10 0 6

It worked! Thank you so much!

PaulMartin
Shopify Partner
251 39 72

You're welcome!

Open to help people out, just email me here or tag me by using "@" when posting your comment