Storefront price format based on B2B customer (or not)

Hi folks! I hope everyone is well.

I’m currently re-working our site to be more B2B friendly under Shopify’s new(!) B2B function when on a Shopify Plus contract.

Prior to recent updates, I ran some code which altered the way prices are shown on products to reflect if they included VAT or not (depending on customer tag).

It seems this is no longer working, and I’m looking to use the new “B2B?” customer identifier, but can’t quite figure out how it works. Can someone kindly assist me please?

Previously I ran the code based on the customer tag (either tagged wholesale or retail) but as mentioned this no longer works. When I log in with an account tagged as Wholesale, prices do not show, but if I alter my account to show retail, it works.

Here is the code we have at present, which no longer functions. What I’d like to show is something along the lines of: “if customer = b2b (show price not including VAT) - else: show price including VAT”

My issue is using the “If customer.b2b? = true” and how to grab a hold of that using a “for” function.

Any assistance would be massively appreciated!


      

        {%- if product.selected_or_first_available_variant.compare_at_price > product.selected_or_first_available_variant.price -%}
          
			{% for tag in customer.tags %}
             	{% if tag == "WHOLESALE" %} 
            
              {{- product.selected_or_first_available_variant.price | times: 1 | money -}}+VAT. ______RRP: £{{ product.metafields.custom.rrp.value }}
          
			{% endif %}
        		{% endfor %}
        
        {% for tag in customer.tags %}
             	{% if tag == "RETAIL" %} 
            
{{- product.selected_or_first_available_variant.price | times: 1.2 | money -}} INC. VAT. _
			{% endif %}
        		{% endfor %}
      
      {% if customer %}
        {%- else -%}
 
              {{- product.selected_or_first_available_variant.price | times: 1.2 | money -}} INC. VAT. _

    {% endif %}

I’ve figured out the solution - but in a very weird way.

The problem was not that Shopify have updated the B2B function that has rendered our code redundant, it’s that the code I’d written was "if customer tagged == “WHOLESALE” (do stuff)

Shopify has took it upon itself to alter all of our tags for “WHOLESALE” and changed them to “Wholesale”.

As my code is case sensitive, this no longer functioned.

Since altering our code to show “Wholesale” instead of “WHOLESALE” - everything works!

1 Like