B2B-Ready Data Layer
This guide covers what Groundwork's B2B support does today and what it only documents. Quantity rules and volume pricing work end to end against real Storefront API fields, on any store, B2B account or not. Company accounts, negotiated catalogs and net-terms checkout are documented in detail, down to the exact API calls and the exact files to touch. They need a Shopify Plus store with B2B enabled, so Groundwork doesn't fake them.
It's for a developer scoping a B2B or wholesale storefront, or an agency lead who has to tell a client honestly what their current Shopify plan covers and what upgrading to Plus would add. Afterwards you'll know which components already respect a variant's quantity rule, and the three concrete steps a Plus upgrade would require (signed-in company context, company-specific catalog pricing, net-terms checkout).
Before you start: this doc assumes you know app/lib/context.ts's request-scoped context pattern, covered in Architecture.
Related: Architecture for the extension-points list this guide's summary line comes from, and Bundles & Upsell for another feature that ships as a rendering pattern instead of a full engine.
Source: docs/guides/b2b.md
This template ships a working slice of Shopify's B2B/wholesale primitives end to end: quantity rules and volume (tiered) pricing. It also documents the rest of what a full B2B storefront needs (company accounts, negotiated catalogs, net-terms checkout) without building all of it. The goal is that adding real B2B support later means extending what's here, so nobody starts from nothing.
What's implemented (Core tier)
Quantity rules. ProductVariant.quantityRule (minimum, maximum, increment) is a real Storefront API field. It's set per variant in the Shopify admin, and it applies whether or not the buyer is a B2B customer (a "sold by the case" rule isn't exclusively wholesale). products.$handle.tsx's PRODUCT_VARIANT_FRAGMENT queries it; <QuantitySelector> (app/components/QuantitySelector.tsx) renders a stepper that respects it, and clampQuantityToRule/getQuantityRuleMessage (app/lib/b2b.ts) do the actual clamping and messaging, fully unit tested.
Volume pricing. ProductVariant.quantityPriceBreaks (a list of {minimumQuantity, price} tiers) is also real Storefront API data, configured per variant. <ProductForm>'s <VolumePricing> shows the tier table and the effective per-unit price for the currently-selected quantity, via getPriceForQuantity (app/lib/b2b.ts).
Both are wired into ProductForm.tsx today. To see them work, the only store configuration you need is quantityRule/quantityPriceBreaks set on a variant.
Documented but not wired up
Company accounts and B2B catalogs require a Shopify Plus store with B2B enabled, plus the Customer Account API's company data (customer.companyContacts, Company, CompanyLocation). None of those exist on a standard/Core store, so this template doesn't assume them. Enabling it for real would involve three steps:
- Signed-in company context. Once a B2B customer authenticates via Customer Account API login (Hydrogen's
/account/loginhandler, wired inapp/lib/customer-account.ts, already handles regular customer login, and B2B login uses the same flow), fetch theircompanyContactsto find theirCompanyLocation, and set it as the cart's buyer identity:
```ts // Somewhere after customer login, e.g. a loader or action: const {customerAccount, accessToken} = await requireCustomerAccessToken( context.get(customerAccountContext), request, ); const {data} = await customerAccountGraphql( customerAccount, accessToken, COMPANY_LOCATIONS_QUERY, ); const companyLocationId = data?.customer.companyContacts.nodes[0]?.company.locations.nodes[0]?.id;
if (companyLocationId) { // A cartBuyerIdentityUpdate mutation against the visitor's cart, // written the same way as the gift-card mutations in // app/lib/cart-mutations.ts (getCartId(request) finds the cart). } ```
Hydrogen 2026-10's cart handler (/api/cart) has no buyer-identity intent, so this is an app-owned mutation; after it, the browser's cart store picks the change up with useCartActions().refresh(). Hydrogen can also keep the customer on the cart in step with login on its own: pass the customer session to both createCartServerHandlers and createCustomerAccountServerHandlers (the hydrogen-customer-account skill in node_modules/@shopify/hydrogen/skills/ shows the wiring). The company location still has to be set explicitly.
- Company-specific catalog and pricing. Once
buyerIdentity.companyLocationIdis set on the cart,@inContextproduct queries automatically return that company's negotiated prices and catalog restrictions. The samecountry/language@inContextmechanismapp/lib/storefront.tsalready uses for the market switcher (see the multi-currency/locale note above) extends tobuyerIdentitythe same way. You don't need a new query shape; just passbuyerIdentitythrough. - Net-terms / PO checkout. This is a Shopify Plus B2B checkout configuration (payment terms, purchase orders), and the storefront app doesn't control it. It's set up in the Shopify admin once a company's payment terms are configured, and Shopify's checkout handles the rest.
What to change if you enable full B2B
app/lib/cart-mutations.ts: add thecartBuyerIdentityUpdatemutation;buyerIdentitythen flows through the cart's existing@inContextwiring.- A new loader (likely in
root.tsxor a dedicated account route) to resolve the signed-in customer's company location on login. app/lib/b2b.ts: no change needed;clampQuantityToRule,getQuantityRuleMessage, andgetPriceForQuantitywork the same whether the buyer is B2B or not.