Identify the customer
Lesson 7 of 18 8 min read
Decide whether orders go to one generic customer or are matched to real customer accounts, including POS and B2B companies.
Every order in your back-office system belongs to a customer. For a consumer web shop that's often one generic "web sales" account; for a wholesale or B2B store, each order needs to land on the right trade account. In this lesson you'll choose the customer strategy that fits your business and learn the settings behind it.
Three common strategies
| Strategy | Typical business | Settings involved |
|---|---|---|
| Everything to one customer | Consumer web shop where finance only needs a total | defaultCustomerId with alwaysSetDefaultCustomerId |
| Match where possible, fall back to a generic customer | Mixed retail and trade | defaultCustomerId, plus identification rules |
| Match every order to a company | Shopify B2B with company accounts | useCompanyExternalIdForIdentification, usePurchasingCompanyLocation, identification rules |
Fallback and generic customers
| defaultCustomerId | The ID of a customer record in Supply Lens to use when an order has no identifiable customer. Think of it as the guest or anonymous customer. |
|---|---|
| alwaysSetDefaultCustomerId | When true, every order goes to the defaultCustomerId, whether or not a customer could be identified. Use it when all orders should sit on one generic account. |
When to choose which. If finance only wants web sales as a single customer, set
defaultCustomerId and turn on alwaysSetDefaultCustomerId. If you want to match real
customers where you can, set defaultCustomerId but leave alwaysSetDefaultCustomerId
off, so the default is only a safety net.
Point-of-sale customers
| posCustomerId | The customer record to use for Shopify POS orders that have no customer on them, such as a walk-in or counter-sales account. |
|---|---|
| alwaysSetPosCustomerId | When true, every POS order goes to the posCustomerId, even if a customer is attached in Shopify. |
These only matter if you've turned on includePos. Use them to keep till sales on their
own account, separate from web orders.
Matching customers from data on the order
Sometimes the customer's account code is stored on the order itself, in a metafield (an extra field Shopify lets apps and admins add) or a custom attribute (a name and value attached to the order, sometimes called a note attribute).
| metafieldCustomerIdentification | A list of rules that read the customer identifier from a Shopify metafield on the order. Rules are tried in order and the first one that matches wins. |
|---|---|
| customAttributeCustomerIdentification | A list of rules that read the customer identifier from a custom attribute on the order. Each rule names the customAttributeKey and the partyIdentifierType. |
Each metafield rule has these parts:
| metafieldKey | The metafield to read. |
|---|---|
| partyIdentifierType | What kind of identifier the value is, for example customer-code or email. |
| jsonPath | Optional. Picks one value out of a metafield that holds structured (JSON) data. |
| pattern, replacement, groupNumber, groupName | Optional. A regular expression (a text-matching pattern) to pull out or reshape part of the value. Ask your implementer if you need these. |
Tip
The value has to match an identifier on the customer's Party record in Supply Lens. If your rule reads a customer code, make sure the same code is held against the customer.
Shopify B2B companies
Shopify B2B lets a company buy, with one or more locations (ship-to addresses).
| useCompanyExternalIdForIdentification | When true, the Shopify company’s external ID is used to match the customer, instead of Shopify’s own internal ID (its GID). Use it when your customers are keyed on a reference you store in Shopify’s external ID field, such as your ERP account code. |
|---|---|
| usePurchasingCompanyLocation | When true, address and contact details come from the purchasing company’s location rather than the company itself. Use it when one company has several ship-to locations. |
Two stores, two strategies
Hilltop Coffee sells to consumers. Priya sets defaultCustomerId to the
SHOPIFY WEB customer and turns on alwaysSetDefaultCustomerId. Every web order lands on
one account.
Northbank Catering Supplies runs a Shopify B2B store for restaurant groups. Each
company in Shopify has its ERP account code in the external ID field, and one group has
eight restaurants. Their implementer turns on useCompanyExternalIdForIdentification so
orders match the ERP account, and usePurchasingCompanyLocation so each order ships to
the right restaurant. A defaultCustomerId catches any order that can't be matched.
Recap
- Choose between one generic customer, match-with-fallback, or company matching for B2B.
defaultCustomerIdis the fallback;alwaysSetDefaultCustomerIdforces it on every order.posCustomerIdandalwaysSetPosCustomerIdhandle till sales.- Metafield and custom-attribute rules read the customer identifier from the order.
- For Shopify B2B, use the company external ID and purchasing company location settings.
Quick guides for this topic
Your progress is saved in this browser. Create a free account to keep it everywhere, take quizzes and earn certificates.