# Shopify Companies

URL: https://docs.sparklayer.io/help/platforms/shopify/companies
Applies to: Shopify

How SparkLayer syncs your Shopify B2B companies, locations and contacts, which side you manage them on, and how orders and vaulted cards are linked.

> **Companies needs SparkLayer 5.** New stores have it. To switch an existing store:
>
> 1. Go to **Storefront > Widgets > SparkLayer version** in the SparkLayer Dashboard ([open](https://app.sparklayer.io/configuration/frontend/core)), or **SparkLayer Wholesale > Storefront > Widgets > SparkLayer version** in the Shopify app.
> 2. Under **Version for this store**, choose **Always use latest 5.x**.
> 3. Click **Save version**.

> **Quick summary**
>
> - Turn on the **Shopify B2B companies** setting and your Shopify B2B companies, their locations and their contacts show in SparkLayer at **Companies** in the SparkLayer Dashboard ([open](https://app.sparklayer.io/customers/companies)), or **SparkLayer Wholesale > Companies** in the Shopify app. They're managed in Shopify. You set each company's terms, such as its customer group and price list, in SparkLayer or with [company metafields](#company-metafields) in Shopify. Prices, payment methods and order rules come from SparkLayer, not from Shopify catalog prices or payment terms. A Shopify catalog still controls which products a company sees.
> - SparkLayer links its draft orders to the buyer's Shopify company and location, so orders show under the company and customers can use Shopify's vaulted cards.
> - Companies are optional: customers without one buy at their customer group's settings. Using Shopify Companies may mean extra transaction costs from Shopify, so check with Shopify Support.

## How it works

**Shopify Companies** is part of Shopify's native B2B features, now on every Shopify plan. You find it at **Customers > Companies** ([open in the Shopify admin](https://admin.shopify.com/companies)). A Shopify company has a profile, **locations** (offices, branches or warehouses, each with its own addresses) and **customers** (the contacts who buy for it).

SparkLayer works with those records. It links its draft orders to the buyer's Shopify company, contact and location, so orders show under the company in your Shopify admin.

With the **Shopify B2B companies** setting on at **Settings > Configurations** in the SparkLayer Dashboard ([open](https://app.sparklayer.io/configuration/settings/general)), or **SparkLayer Wholesale > Integrations > Platform** in the Shopify app, each Shopify company is a [company](https://docs.sparklayer.io/help/customers/companies.md) in SparkLayer, and its contacts are the people at that company. The sync runs one way, from Shopify to SparkLayer. Manage the company, its locations and its contacts in Shopify. Set its terms, such as its **Customer group**, **Price list**, pay later, sales reps and address settings, on its page in SparkLayer, or with [company metafields](#company-metafields) in Shopify.

How Shopify companies and SparkLayer work together:

1. **Company in Shopify**: You create and change it at Customers > Companies
2. **Synced to SparkLayer**: The company, its locations and contacts show in SparkLayer
3. **Terms set**: On its page in SparkLayer, or with metafields in Shopify
4. **Orders linked**: Draft orders are linked to the company, contact and location in Shopify

With the sync off, you can [build companies in SparkLayer](#companies-built-in-sparklayer) instead.

SparkLayer still identifies B2B customers by their `b2b` customer tag and puts them in customer groups by their group tag (such as `b2b-trade`). A company's customer group sets the terms for the people at that company. 

## Do you need Shopify Companies?

Companies are optional. Use this table to decide before you set them up.

| If you want to… | Then |
| --- | --- |
| Give a business its own prices, payment terms or sales reps | Use companies. Build them in SparkLayer with the sync off, where you set the terms on each company. |
| Let several people buy for one business, or split a business into stores or regions | Use companies and [company locations](https://docs.sparklayer.io/help/customers/company-locations.md). |
| See B2B orders grouped by company in your Shopify admin | Use companies. SparkLayer links their orders automatically. |
| Sell to individual B2B customers on the same terms | You don't need companies. Customer groups handle everything. |

## Set up your companies

First choose where you'll manage them:

- **In Shopify:** [turn on the **Shopify B2B companies** setting](https://docs.sparklayer.io/help/customers/companies.md#turn-on-shopify-b2b-companies), then create your companies, their locations and their contacts at **Customers > Companies** ([open in the Shopify admin](https://admin.shopify.com/companies)). They show in SparkLayer. Set each company's terms there, or with [company metafields](#company-metafields). Change its name, locations and contacts in Shopify.
- **In SparkLayer:** leave the sync off and click **Create company** at **Companies** in the SparkLayer Dashboard ([open](https://app.sparklayer.io/customers/companies)), or **SparkLayer Wholesale > Companies** in the Shopify app. Set each company's **Customer group**, **Price list**, **Let them pay later**, people and [locations](https://docs.sparklayer.io/help/customers/company-locations.md) there. See [Companies](https://docs.sparklayer.io/help/customers/companies.md).

## Set a company's terms with metafields

With the **Shopify B2B companies** setting on, you can set a company's terms in either of 2 places:

- **In SparkLayer**, on the company's page.
- **In Shopify**, with a SparkLayer metafield on the company.

Metafields are optional. Use them if you'd rather keep a company's terms in Shopify with the rest of the company. Shopify companies don't have tags, so a metafield is the only way to set a company's customer group from Shopify.

You can mix the 2. For example, set the **Customer group** in Shopify and **Pay later** in SparkLayer. Each field follows the rule below on its own.

### How it works

There's one rule: **if a metafield has a value, Shopify decides. If it's empty, SparkLayer decides.**

How a company metafield reaches SparkLayer:

1. **Fill it in on Shopify**: Enter a value on the company in Shopify
2. **It syncs across**: The value replaces what SparkLayer had for that field
3. **The field locks**: From now on, change that field in Shopify

| What you do in Shopify | What happens in SparkLayer |
| --- | --- |
| Leave a metafield empty | Nothing. You set that field in SparkLayer as usual. |
| Add a value | The value replaces what SparkLayer had. The field locks on the company's page, with the hint "Set by the B2B - Customer Group metafield in Shopify. Remove it there to set it here." |
| Change the value | SparkLayer updates to the new value. The field stays locked. |
| Remove the value | The field unlocks and **keeps its last value**. It doesn't reset. Change it in SparkLayer if you want something else. |
| Enter a value SparkLayer can't read | That company or location stops updating in SparkLayer until you fix the value. This includes its name and its other terms. |

> **Removing a value doesn't undo it**
>
> To take a company off a price list, removing the metafield isn't enough: the company keeps the price list. Remove the metafield in Shopify, then remove the price list on the company's page in SparkLayer. To turn off an address setting, set its metafield to `false` instead of leaving it empty.

### The 6 company metafields

Each one shows in Shopify with a name starting `B2B -`.

| Metafield in Shopify | What it sets | Where you can use it |
| --- | --- | --- |
| **B2B - Customer Group** | The company's [customer group](https://docs.sparklayer.io/help/customers/customer-groups.md), which sets its pricing and rules | Company or location |
| **B2B - Price Lists** | The [price lists](https://docs.sparklayer.io/help/pricing/customer-pricing.md) its buyers get | Company or location |
| **B2B - Payment on Account** | Whether it can pay later, with its credit limit, balance and net terms | Company only |
| **B2B - Sales Agent Groups** | The [sales rep groups](https://docs.sparklayer.io/help/sales-reps.md#restrict-which-customers-a-sales-agent-can-see) that look after it | Company only |
| **B2B - Allow Personal Addresses** | Whether buyers can use their own saved addresses as well as the company's | Company or location |
| **B2B - Allow One-time Addresses** | Whether buyers can enter a one-off address at checkout | Company or location |

What to enter in each:

| Metafield in Shopify | What to enter | Example |
| --- | --- | --- |
| **B2B - Customer Group** | The group's [tag](https://docs.sparklayer.io/help/customers/add-customers-to-a-group.md#find-a-groups-tag). For the Base group, enter `base`, not `b2b`. | `b2b-trade` |
| **B2B - Price Lists** | A list of price list handles. Use the form below. | `["trade-25","clearance"]` |
| **B2B - Payment on Account** | Its [account details](https://docs.sparklayer.io/help/ordering/credit-net-terms-and-invoicing.md#what-to-enter). Use the form below. | `{"credit_limit":1000}` |
| **B2B - Sales Agent Groups** | One group per entry, using letters, numbers and dashes. | `uk-north` |
| **B2B - Allow Personal Addresses** | `true` or `false` | `true` |
| **B2B - Allow One-time Addresses** | `true` or `false` | `false` |

For a customer group, `b2b-trade` and `trade` both mean the Trade group: SparkLayer ignores the `b2b-` at the start.

To write a **B2B - Price Lists** value, add each price list's handle here, then copy the result:

To write a **B2B - Payment on Account** value, fill this in and copy the result. Leave out anything you don't use, and enter amounts without a currency symbol.

**Namespaces, keys and types, for developers and imports**

All 6 use the `sparklayer` namespace.

| Metafield in Shopify | Key | Type | Owner |
| --- | --- | --- | --- |
| **B2B - Customer Group** | `customer_group` | `single_line_text_field` | Company, company location |
| **B2B - Price Lists** | `price_lists` | `json` | Company, company location |
| **B2B - Payment on Account** | `payment_on_account` | `json` | Company |
| **B2B - Sales Agent Groups** | `sales_agent_groups` | `list.single_line_text_field` | Company |
| **B2B - Allow Personal Addresses** | `allow_personal_addresses` | `boolean` | Company, company location |
| **B2B - Allow One-time Addresses** | `allow_one_time_addresses` | `boolean` | Company, company location |

### Check the metafields are set up

You don't need to create these metafields. SparkLayer creates all 6 in Shopify when you [turn on the **Shopify B2B companies** setting](https://docs.sparklayer.io/help/customers/companies.md#turn-on-shopify-b2b-companies). If you've already made one by hand, SparkLayer keeps it and doesn't add a duplicate.

To check they're there:

1. Go to **Integrations > Platform > Configurations** in the SparkLayer Dashboard ([open](https://app.sparklayer.io/configuration/integrations/platform)), or **SparkLayer Wholesale > Integrations > Platform > Configurations** in the Shopify app and click **Configure** next to **Configure metafields**.
2. Find **Company metafields**. Each one should show **Enabled**.
3. If one doesn't, click the button beside it: **Retry** or **Enable**. 

The list has **Customer metafields** too, and some share a name, such as **Sales rep groups**. Those are for customers. Only the ones under **Company metafields** work on a company.

### Fill in a metafield

1. In your Shopify admin, go to **Customers > Companies** ([open in the Shopify admin](https://admin.shopify.com/companies)) and click the company. For a location, click the location on the company's page.
2. Find the metafields with names starting `B2B -`. 
3. Enter the value, using [the list above](#company-metafield-list). Leave any you don't need empty.
4. Click **Save**.
5. In SparkLayer, go to **Companies** in the SparkLayer Dashboard ([open](https://app.sparklayer.io/customers/companies)), or **SparkLayer Wholesale > Companies** in the Shopify app and open the company. The field shows your value, with the hint that it's set by the metafield. 

If the field hasn't changed, see [the FAQs](#company-metafield-faqs).

### Companies and locations

A location uses its company's terms until it has its own. See [Company locations](https://docs.sparklayer.io/help/customers/company-locations.md).

| To do this | Do this |
| --- | --- |
| Give the whole company a customer group, price list or address setting | Fill in the metafield on the company. |
| Give one location something different | Fill in the same metafield on that location. That location's value applies there, and the other locations aren't affected. |
| Give one location its own pay later or sales reps | Use SparkLayer. **B2B - Payment on Account** and **B2B - Sales Agent Groups** only work on the company, so set these on the location's page. |

### Example

A wholesale company buys at your Trade prices, with a 5,000 credit limit and Net 30 terms. Its Berlin location should use your Europe group instead. In Shopify, you'd enter:

| Where | Metafield | Value |
| --- | --- | --- |
| The company | **B2B - Customer Group** | `b2b-trade` |
| The company | **B2B - Payment on Account** | `{"credit_limit":5000,"net_terms":"30_days"}` |
| The Berlin location | **B2B - Customer Group** | `b2b-europe` |

In SparkLayer, the company is then in the Trade group, and its **Customer group** and pay later settings are locked. Berlin is in the Europe group, and every other location stays on Trade. The other metafields are empty, so you set the company's price lists, sales reps and address settings in SparkLayer.

### FAQs about company metafields

**Why is a field locked on the company's page?**

A metafield in Shopify is setting it. The hint under the field names the metafield. Change the value in Shopify, or remove it to set the field in SparkLayer.

**I saved a metafield, but the company hasn't changed**

Check these in order:

- **The setting is on.** SparkLayer only reads company metafields while the **Shopify B2B companies** setting is on.
- **It's on the company.** A metafield on the company's contact, under **Customers**, doesn't set the company's terms.
- **It's the SparkLayer metafield.** Its namespace must be `sparklayer`. A metafield Shopify suggests under `custom` isn't read.
- **The value is valid.** Check it against [the list of metafields](#company-metafield-list). One bad value stops that company or location updating. 
- **The customer group exists.** The value must match a group at **Customers > Groups** in the SparkLayer Dashboard ([open](https://app.sparklayer.io/customers/groups)), or **SparkLayer Wholesale > Companies > Customer groups** in the Shopify app.

**I removed a metafield, but the company still has the old value**

That's expected. Removing a value unlocks the field and leaves it as it was. Change it on the company's page in SparkLayer.

**Which wins if SparkLayer and Shopify have different values?**

The metafield, if it has a value. SparkLayer takes it from Shopify and locks the field, so the 2 can't stay different. If the metafield is empty, SparkLayer's value stands.

**Do these work with the setting off?**

No. With the setting off, SparkLayer doesn't read company metafields, and you set everything on the company's page. If you turn it off later, the metafields and their values stay in Shopify.

## Companies built in SparkLayer

With the **Shopify B2B companies** setting off, you can build companies in SparkLayer without using Shopify Companies. Click **Create company** at **Companies** in the SparkLayer Dashboard ([open](https://app.sparklayer.io/customers/companies)), or **SparkLayer Wholesale > Companies** in the Shopify app, then add its locations and people there.

> **Turning on the integration replaces companies built in SparkLayer**
>
> If you turn on the **Shopify B2B companies** setting later, your Shopify companies replace the companies you built in SparkLayer, along with their locations, people and settings. From then on, companies are managed in Shopify, and you set their terms in SparkLayer or with [company metafields](#company-metafields).

So if there's a chance you'll use Shopify Companies, create your companies in Shopify from the start.

## How draft orders are linked to companies

When SparkLayer creates a draft order for a buyer at a company, it links the order to their Shopify **company**, **contact** and **location**. This keeps your Shopify orders and reports accurate.

Linking a SparkLayer order to a Shopify company:

1. **Buyer orders**: A buyer at a company places an order through SparkLayer
2. **Draft order created**: SparkLayer creates a draft order in Shopify
3. **Company linked**: The order is linked to the buyer, their company and the location
4. **Shown in Shopify**: The order appears under both the customer and the company

What the order is linked to depends on how the customer is linked to companies in Shopify. This applies to every order SparkLayer creates, including a quote converted to an order.

| The customer is | The order is placed against |
| --- | --- |
| Not linked to a company | The customer only. |
| A contact at one location of one company | The customer, the company and the location. |
| A contact at several locations or several companies | The customer only, because SparkLayer can't tell which location the order is for. |

The delivery address the customer chooses at checkout becomes the Shopify order's shipping address. It doesn't decide which company location the order is linked to.

This means:

- Orders from SparkLayer appear under the company in your Shopify admin. On the orders list, you see the company name under the customer's name.
- Shopify's reports recognise them as B2B orders from that company.
- It resolves Shopify's warning that "Some apps may not attribute B2B orders correctly on your current plan. Check that B2B orders are assigned to a company, not just an individual customer."

## Use vaulted credit cards

Because SparkLayer links draft orders to the customer's company and location, your B2B customers can use [Shopify's vaulted credit cards](https://help.shopify.com/en/manual/b2b/checkout-and-orders/vaulted-cards). They save a card once and reuse it on later orders.

Vaulted cards belong to a **company location**. When a customer saves a card, at checkout or in their customer account, it's available to every customer linked to the same company location. With SparkLayer, they work in 2 ways:

- **Pay Online by Card**: when a customer chooses **Pay Online by Card** in the SparkLayer checkout, the cards saved for their company location appear under **Credit card** in the Shopify checkout. They can choose one, or click **Use a different card**.
- **Draft orders and invoices**: when a customer uses another payment method (for example Pay by Invoice), you can charge a vaulted card on the resulting draft order from your Shopify admin. On the draft order, click **Collect payment** and choose the saved card.

### Before you start

- **Shopify Payments turned on.** Vaulted cards need Shopify Payments as your payment provider.
- **Customers linked to a Shopify company.** The customer must be a contact of a company in your Shopify admin.
- **A saved card.** Someone at the company location must have saved a card during a checkout or in their customer account. Once it's saved, every customer at that location can use it.

There's nothing to set up in SparkLayer. Vaulted cards work in the SparkLayer checkout as long as customers are linked to Shopify companies and Shopify Payments is active. They're available on every Shopify plan that has the Companies feature. Check any transaction fees with Shopify Support.

### Control who can use vaulted cards

To stop some of a customer's team from using vaulted cards, use SparkLayer's [company users](https://docs.sparklayer.io/help/customers/company-users.md) feature. Give those team members the **Limited** role. They can browse and build an order, but they can't check out: their order goes to the main company user for approval instead. Because limited users never reach the Shopify checkout, they can't charge a card saved for the company location.

## Limitations

- **Shopify catalogs still control which products a company sees**: SparkLayer's price lists replace the prices in a Shopify catalog, but not the catalog's product list. If a customer is a contact at a Shopify company whose catalog leaves a product out, Shopify hides it from them: it's missing from your theme's search and its page shows a 404, even when SparkLayer gives them a price. Add the products to the catalog, remove the catalog from the company, or don't use Shopify companies for these customers.
- **Shopify payment terms aren't used**: payment rules come from SparkLayer's customer groups, set on the company or location in SparkLayer. The payment terms on Shopify company records are ignored. 
- **Shopify's locations don't nest**
  : in Shopify, a company's locations sit side by side. Grouping them into regions, with locations inside other locations, is a SparkLayer feature. 

- **Customers linked to several locations or companies**: if a customer is a contact at more than one location or Shopify company, their draft order is placed against the customer only, not a company.
- **Customers not in a company**: their orders are linked to the customer only.

## FAQs

**Do I need Shopify Companies to use SparkLayer?**

No. Customers who aren't in a company buy at their customer group's settings, and you add them to a group with a tag. Use companies to see B2B orders grouped by company in Shopify, or to let colleagues share vaulted cards, or when a business needs its own terms, several people buy for it, or it has several locations.

**If I change a company in Shopify, does SparkLayer update?**

Yes, with the **Shopify B2B companies** setting on. Companies, locations and contacts sync from Shopify to SparkLayer. It doesn't work the other way, so change the company, its locations and its contacts in Shopify. In SparkLayer, you choose its **Customer group** and **Price list**.

**Can I use SparkLayer and Shopify's native B2B checkout at the same time?**

Not for the same customer session: the ordering experience is either SparkLayer or Shopify's native B2B checkout. Your Shopify companies still hold the business, its locations and its contacts, and SparkLayer uses them for ordering.

**Should I tag customers or set up Shopify companies?**

Both work together. Tags make someone a B2B customer and put them in a customer group. Companies group the people who buy for the same business, and let you give that business its own terms and locations.

**Do I need Shopify Markets to use Shopify Companies?**

Not for SparkLayer pricing. Companies and Markets are separate features, but on plans other than Plus they're closely linked.

You can create company records without Markets. They work as structured customer profiles with locations, contacts and payment terms. But to give those companies their own Shopify pricing catalogs, you need Markets: on the Basic, Grow and Advanced plans, catalogs are assigned through Markets (customer groupings), not directly to companies. On Shopify Plus, you can assign catalogs directly to company locations without Markets.

SparkLayer doesn't use either for pricing. Your price lists and customer groups, and each company's terms, are managed in SparkLayer, whether or not you use Markets.

**What about Shopify's warning that apps may not attribute B2B orders correctly?**

SparkLayer handles it. It links draft orders to the right Shopify company and location, so B2B orders are attributed correctly in your Shopify admin.

**Does the delivery address at checkout choose the company location?**

No. The address the customer chooses at checkout becomes the order's shipping address in Shopify, but it doesn't change which company or location the order is linked to. See [How draft orders are linked to companies](#how-draft-orders-are-linked-to-companies).

**Do customers need to be in a company to request a quote?**

No. Customers can [request a quote](https://docs.sparklayer.io/help/ordering/quoting.md) whether or not they're linked to a Shopify company. When you convert the quote to an order, it's linked in the same way as any other order: see [How draft orders are linked to companies](#how-draft-orders-are-linked-to-companies).

## Next steps

- [Add B2B customers on Shopify](https://docs.sparklayer.io/help/platforms/shopify/invite-customers.md): Tag a customer you already have, or add a new one, so they see trade prices
- [Customer groups](https://docs.sparklayer.io/help/customers/customer-groups.md): Set the pricing and rules your B2B customers get in SparkLayer
- [Shopify limitations](https://docs.sparklayer.io/help/platforms/shopify/limitations.md): What SparkLayer can and can't do on Shopify
