Tom Sailors
· Refreshed
Brief · Anonymized case study

Wholesale Collection Gate

Restrict wholesale collections to B2B-tagged customers by rendering a 404 for anyone lacking the tag. Gate collection pages at the template level using Liquid conditionals, hide wholesale links from retail navigation and search, automatically tag verified business accounts via Shopify Flow or manual admin review, and ensure incoming B2B customers are tagged before they access storefronts.

A B2B-focused merchant needs to restrict access to wholesale collections to verified business accounts only. Retail customers should encounter a 404 when attempting to reach these collections directly—not a redirect or fallback. The merchant relies on customer tags to designate B2B status and must ensure the collection access rules enforce that tag check consistently across direct navigation, search, and the storefront.
Four pieces
Storefront

Collection Tag Gate

Checks if the logged-in customer has the b2b tag; if not, renders a 404 page instead of the collection.

Theme collection template + Liquid
theme/templates/collection.json (or theme/snippets/collection-gate.liquid called early in the template) liquid
{% assign customer_is_b2b = false %}
{% if customer %}
  {% if customer.tags contains 'b2b' %}
    {% assign customer_is_b2b = true %}
  {% endif %}
{% endif %}

{% if collection.handle == 'wholesale' or collection.handle == 'b2b-only' %}
  {% unless customer_is_b2b %}
    {% assign request.page_type = 'notfound' %}
    {% render 'page-not-found' %}
  {% endunless %}
{% endif %}

{% if customer_is_b2b %}
  <!-- Render normal collection template -->
  <div class="collection">
    <h1>{{ collection.title }}</h1>
    <!-- Your existing collection content here -->
  </div>
{% endif %}
Replace 'wholesale' and 'b2b-only' with actual collection handles. The tag name 'b2b' must match the tag assigned to B2B customer records in the Shopify admin.
B2B / Wholesale

B2B Customer Tag Sync

Automatically tags customers in Shopify when they sign up through a B2B company portal or are manually approved.

Custom Shopify app + admin dashboard
Admin GraphQL explorer graphql
# Admin GraphQL
mutation TagB2BCustomer($customerId: ID!, $tags: [String!]!) {
  customerUpdate(input: { id: $customerId, tags: $tags }) {
    customer {
      id
      email
      tags
    }
    userErrors {
      field
      message
    }
  }
}

# Variables example:
# {
#   "customerId": "gid://shopify/Customer/123456",
#   "tags": ["b2b"]
# }
Tags passed as an array replace existing tags entirely; to append without removing others, fetch the customer's current tags first, merge, then update.
Storefront

Search & Nav Blackout

Removes wholesale collections from search results and main navigation menus for retail customers; B2B accounts see them normally.

Theme snippets + Liquid conditionals
theme/snippets/main-nav.liquid (or header/navigation snippet) liquid
{% assign show_wholesale_nav = false %}
{% if customer and customer.tags contains 'b2b' %}
  {% assign show_wholesale_nav = true %}
{% endif %}

<!-- In your navigation or menu loop: -->
{% for link in linklists.main-menu.links %}
  {% assign is_wholesale_collection = false %}
  {% if link.type == 'collection_link' %}
    {% if link.object.handle == 'wholesale' or link.object.handle == 'b2b-only' %}
      {% assign is_wholesale_collection = true %}
    {% endif %}
  {% endif %}
  
  {% unless is_wholesale_collection and show_wholesale_nav == false %}
    <li><a href="{{ link.url }}">{{ link.title }}</a></li>
  {% endunless %}
{% endfor %}
Adjust the collection handle list to match wholesale collections. This hides links but does not prevent direct URL access — rely on the Collection Tag Gate for that enforcement.
Operations

B2B Verification Workflow

A manual or automated process to review and tag new accounts as B2B within the Shopify admin, so they unlock collection access immediately.

Shopify Flow + admin custom columns
Shopify Flow editor: When → Then flow
Trigger: Customer created or updated (by staff in admin)
Condition: Customer.email contains specific domain (e.g., @yourb2bpartner.com) OR customer added to a specific group/tag
Then: Tag customer with "b2b"
Alternative: Trigger a Shopify admin notification for manual review → Staff reviews → Tags customer in admin directly

For semi-automated: Trigger on order > X value from new customer → Assign "b2b" tag → Send approval email to staff.
Pure automation (domain-based tagging) is fast but may mis-tag. Manual review is slower but safer. Hybrid (threshold-based notification) balances both.

Got a similar problem?

Sketch your build in 30 seconds — voice, type, or attach a screenshot.

Sketch the build →