Skip to content

Shopify Dude Fix

Shopify B2B Buyers Can’t Switch Company Locations: Add a Location Picker to the Theme

A B2B customer can belong to several company locations, but the storefront must expose the current purchasing context. Use Shopify’s Liquid company-location objects and native switching URL.

Type: Fix / Developer Guide · Stage: Scale · Topic: B2B / Company Locations / Liquid

On this page

Quick answer

A B2B buyer who purchases for multiple branches needs a visible way to confirm and, where permitted, change the company location associated with the transaction. Shopify exposes customer.current_company, customer.current_location, customer.company_available_locations, and a location’s url_to_set_as_current in theme Liquid. If the header only says “Welcome back,” it may be hiding a critical purchasing decision.

Company locations matter because Shopify B2B can assign different catalogs, prices, payment terms, taxes, and shipping settings to different branches. A buyer should know which branch is purchasing before they add products to the cart.

Why the location switcher is missing

Consumer themes generally treat the logged-in customer as the entire identity context. B2B introduces a second question: Which company location is this purchase for? Shopify’s B2B theme documentation recommends displaying the current company and location and providing a picker when the customer can use more than one. A theme that ignores those objects may work for single-location buyers while confusing multi-location customers.

Do not confuse a B2B company location with a warehouse fulfillment location. Company locations identify the purchasing branch; fulfillment locations identify where inventory ships from. Their IDs and permissions are unrelated.

Check permissions before editing Liquid

  1. Open Customers → Companies in Shopify admin and inspect the company and its locations.
  2. Confirm the buyer is assigned to the expected locations with the appropriate contact permissions. The location picker must not expose unauthorized branches.
  3. Check each location’s catalogs, payment terms, and shipping configuration. Different prices after switching may be correct.
  4. Test with an authenticated B2B buyer, not only an administrator preview. The current purchasing context depends on the buyer’s session.

Liquid example: current location and available alternatives

{% if customer and customer.b2b? %}
  <div class="b2b-location-switcher">
    <p>Purchasing for:
      <strong>{{ customer.current_company.name | escape }}</strong>
      {% if customer.current_location %}
        — {{ customer.current_location.name | escape }}
      {% endif %}
    </p>
    {% if customer.company_available_locations_count > 1 %}
      <nav aria-label="Choose company location">
        <ul>
          {% for location in customer.company_available_locations %}
            {% unless location.current? %}
              <li>
                <a href="{{ location.url_to_set_as_current }}">
                  {{ location.name | escape }}
                </a>
              </li>
            {% endunless %}
          {% endfor %}
        </ul>
      </nav>
    {% endif %}
  </div>
{% endif %}

The native url_to_set_as_current property is preferable to inventing a switching endpoint or posting arbitrary location IDs from browser JavaScript. This is a minimal example; add theme-consistent styling, keyboard focus states, and a mobile-friendly presentation. For very large location lists, Shopify documents pagination support on the customer location array, so do not assume one unrestricted loop covers every location.

Where to display the selected company

Place the current company/location near the account area or another persistent B2B identity control. Consider repeating it near the cart or order review so the buyer can catch a mistake before submitting an order. A wholesale sales-agent portal that deliberately orders for several companies needs additional authorization and order-creation logic; a location picker alone is not a delegated impersonation system.

After switching, recheck product eligibility, pricing, and the cart. Shopify’s B2B context can affect catalogs and checkout terms. Do not assume a cart assembled for one location will be valid for another. For custom headless storefronts, the Storefront API cart buyer identity must be handled explicitly; this Liquid snippet applies to Online Store theme rendering.

Common misunderstanding

“The customer is logged in, so the correct B2B price will always show.” Login identifies the person; the selected company location can determine the applicable catalog and price.

“A company has three locations, so every employee can select all three.” Not necessarily. Available locations reflect the buyer’s access, not merely the company’s full location list.

“Changing the shipping address is the same as changing the company location.” It is not. A shipping address does not establish the purchasing context that controls catalogs and payment terms.

How to test this

  1. Use a test B2B buyer authorized for two company locations with different catalog prices or payment terms.
  2. Sign in and confirm the switcher displays the current location and only authorized alternatives.
  3. Switch through the native link and reload a product. Verify eligibility, price, and location identity.
  4. Check the cart and complete a controlled checkout. Confirm the resulting order or draft order has the intended company location.
  5. Repeat with a one-location buyer and a non-B2B shopper. The switcher should not show unauthorized or irrelevant choices.
  6. Test mobile, keyboard navigation, and logout/login behavior. Do not let a stale client-side preference override Shopify authorization.

Sources and further reading

Documentation reviewed October 20, 2026.