Navigating B2B & B2C Inventory: Sorting Shopify Collections by Warehouse Location

Hey everyone,

As a migration expert who spends a lot of time diving into the nitty-gritty of Shopify stores and, frankly, lurking in the community forums, I often come across discussions that hit on really common, yet complex, challenges. One recent thread caught my eye because it perfectly illustrates a dilemma many growing businesses face: how to juggle B2C and B2B operations, especially when your inventory lives in different places.

The Multi-Warehouse, Multi-Customer Conundrum

The discussion started with jas407's question, which immediately resonated. They're trying to run both B2C and B2B sales from a single Shopify store, but with a twist: they have two physical warehouse locations. The problem? Their B2C customers should primarily see products from Warehouse 1, while B2B clients need to see only products from Warehouse 2 on collection pages. Shopify, by default, doesn't make this kind of granular, location-based collection sorting simple.

Jas407 mentioned that there's an app out there that can do this, but at $50 AUD per month, they were understandably looking for a more integrated, possibly code-based solution. In fact, they even suggested that a second Shopify store might be a better option for segregating B2C and B2B entirely. And honestly, for some businesses, that is a valid path, despite the added management overhead.

Why It's Not So Simple (and How to Make It Work)

As tim_1 rightly pointed out, "No, it’s actually not that simple." Shopify's native collection sorting and filtering are powerful, but they don't inherently differentiate by inventory location in a way that allows you to dynamically show or hide products based on the customer type and their associated warehouse. However, tim_1 then dropped a gem that points us towards a robust, flexible solution: Shopify Flow combined with product metafields.

Leveraging Shopify Flow and Metafields for Smart Collection Sorting

This approach allows you to "tag" your products with information about their availability at specific warehouses, and then use that information to filter your collections. It's a bit of a custom setup, but it gives you incredible control without needing a separate store or an expensive third-party app.

Step-by-Step: Setting Up Your Location-Based Product Filters

Here’s how you can implement this strategy:

  1. Define Your Product Metafields:
    First, you need a way to store the "available at warehouse X" information on each product. Shopify's metafields are perfect for this.
    • Go to your Shopify Admin -> Settings -> Custom data -> Products.
    • Click "Add definition."
    • Create two new metafield definitions (or more, if you have more warehouses). Let's call them:
      • Name: Available at Warehouse 1, Namespace and key: custom.available_at_warehouse_1, Type: Boolean.
      • Name: Available at Warehouse 2, Namespace and key: custom.available_at_warehouse_2, Type: Boolean.
    • Save your metafield definitions.

    These boolean metafields will be either true or false, indicating availability.

  2. Automate Metafield Updates with Shopify Flow:
    Manually updating these metafields for every product would be a nightmare. This is where Shopify Flow comes in – it's your automation powerhouse.
    • Go to your Shopify Admin -> Apps -> Shopify Flow.
    • Click "Create workflow."
    • Workflow 1: For Warehouse 1 Availability
      • Trigger: Inventory quantity changed (or Product updated if you prefer a broader trigger).
      • Condition: Add a condition that checks:
        • Inventory item quantity at location -> [Select your Warehouse 1 location] -> is greater than -> 0.
      • Action: Update product metafield.
        • Select the Available at Warehouse 1 metafield (custom.available_at_warehouse_1).
        • Set its value to true.
      • You'll also need a complementary branch for when the inventory quantity at Warehouse 1 is 0, setting custom.available_at_warehouse_1 to false.
    • Workflow 2: For Warehouse 2 Availability
      • Repeat the process for Warehouse 2, checking inventory at that specific location and updating custom.available_at_warehouse_2 accordingly.

    This ensures your metafields are always up-to-date based on your actual inventory levels at each location.

  3. Modify Your Theme for Filtering:
    Now for the front-end magic. You'll need to edit your theme's Liquid code, specifically the collection template (often collection.liquid or within a sections/main-collection-product-grid.liquid file).
    • Go to Shopify Admin -> Online Store -> Themes -> Actions -> Edit code.
    • Locate your collection template file.
    • You'll add code to your collection filters to include these new metafields. This might look something like adding a new filter option:
      
      
      

      Important: The exact implementation will depend on your theme's filtering system. Modern themes often use a structured way to add filters, so you might need to consult your theme's documentation or a developer.

    • Conditional Display for B2B/B2C: This is where it gets clever. Tim_1 suggested pre-checking filters based on the logged-in customer. You can achieve this by:
      • Customer Tagging: Tag your B2B customers (e.g., with B2B_Customer).
      • Liquid Logic: In your theme code, you can check if the customer is logged in and has a specific tag.
        {% if customer and customer.tags contains 'B2B_Customer' %}
          
          
          
        {% else %}
          
          
          
        {% endif %}

        This snippet demonstrates the concept. You'd integrate this with your theme's actual filter rendering logic. For B2B customers, you'd hide products not available in Warehouse 2, and vice-versa for B2C.

Considering the "Second Store" Option

Jas407's thought about a second Shopify store for B2B isn't without merit. It offers true separation, simplifying inventory management and pricing rules. However, it means double the subscription fees, double the app costs, and potentially double the marketing and SEO effort. For many, a single store with smart customization like the Flow/metafield approach is a more cost-effective and manageable solution in the long run.

The App Alternative

While jas407 found an app that charges $50 AUD/month, it's worth noting that the app ecosystem is constantly evolving. If the custom code approach feels too daunting, always re-evaluate the app market. Sometimes, the convenience and ongoing support an app provides can justify the cost, especially if it handles all the complexities out-of-the-box.

Ultimately, the Shopify community discussion highlighted a real pain point and offered a powerful, native Shopify solution. By combining Shopify Flow's automation capabilities with the flexibility of metafields, you can create a highly tailored shopping experience for your B2C and B2B customers, all within a single store. It requires a bit of upfront setup and some theme customization, but the control and efficiency you gain are well worth the effort.

Happy customizing!

Share:

Use cases

Explore use cases

Agencies, store owners, enterprise — find the migration path that fits.

Explore use cases