---
title: Create B2B checkout UI
description: Learn how to customize checkout for business customers.
source_url:
html: 'https://shopify.dev/docs/apps/build/b2b/create-checkout-ui'
md: 'https://shopify.dev/docs/apps/build/b2b/create-checkout-ui.md'
---
ExpandOn this page
* [What you'll learn](https://shopify.dev/docs/apps/build/b2b/create-checkout-ui.md#what-youll-learn)
* [Requirements](https://shopify.dev/docs/apps/build/b2b/create-checkout-ui.md#requirements)
* [Sample code](https://shopify.dev/docs/apps/build/b2b/create-checkout-ui.md#sample-code)
* [Step 1: Create a checkout UI extension](https://shopify.dev/docs/apps/build/b2b/create-checkout-ui.md#step-1-create-a-checkout-ui-extension)
* [Step 2: Import components](https://shopify.dev/docs/apps/build/b2b/create-checkout-ui.md#step-2-import-components)
* [Step 3: Set up the targets](https://shopify.dev/docs/apps/build/b2b/create-checkout-ui.md#step-3-set-up-the-targets)
* [Step 4: Configure the metafields](https://shopify.dev/docs/apps/build/b2b/create-checkout-ui.md#step-4-configure-the-metafields)
* [Step 5: Identify a business customer](https://shopify.dev/docs/apps/build/b2b/create-checkout-ui.md#step-5-identify-a-business-customer)
* [Step 6: Identify a draft order checkout](https://shopify.dev/docs/apps/build/b2b/create-checkout-ui.md#step-6-identify-a-draft-order-checkout)
* [Step 7: Deploy the UI extension](https://shopify.dev/docs/apps/build/b2b/create-checkout-ui.md#step-7-deploy-the-ui-extension)
* [Troubleshooting](https://shopify.dev/docs/apps/build/b2b/create-checkout-ui.md#troubleshooting)
* [Next steps](https://shopify.dev/docs/apps/build/b2b/create-checkout-ui.md#next-steps)
# Create B2B checkout UI
Outdated
This tutorial uses an outdated API version for building Checkout UI extensions. We recommend using `2025-10` to make use of new [Polaris web components](https://shopify.dev/docs/beta/next-gen-dev-platform/polaris).
Plus
[Checkout UI extensions](https://shopify.dev/docs/api/checkout-ui-extensions) that render on the information and shipping and payment steps in checkout are available only to stores on a [Shopify Plus](https://www.shopify.com/plus) plan.
In this tutorial, you'll use [checkout UI extensions](https://shopify.dev/docs/api/checkout-ui-extensions) to create a custom B2B checkout experience that renders the content of a banner based on the customer type (B2B or D2C), company metafields, and whether completing the checkout results in submitting a draft order.
***
## What you'll learn
In this tutorial, you'll learn how to do the following tasks:
* Use the [`usePurchasingCompany`](https://shopify.dev/docs/api/checkout-ui-extensions/2023-07/react-hooks/buyer-identity/usepurchasingcompany) hook to identify business customers.
* Use the [`useCheckoutSettings`](https://shopify.dev/docs/api/checkout-ui-extensions/2023-07/react-hooks/metadata/usecheckoutsettings) hook to identify draft order checkouts.
* Get familiar with using `Company` and `CompanyLocation` metafields.
* Deploy your extension code to Shopify.
***
## Requirements
* You're a [user with app development permissions](https://shopify.dev/docs/apps/build/dev-dashboard/user-permissions).
* You've created a new [development store](https://shopify.dev/docs/api/development-stores) with [test data generated by Shopify](https://shopify.dev/docs/api/development-stores/generated-test-data).
* You've [created an app](https://shopify.dev/docs/apps/build/scaffold-app) that uses Shopify CLI 3.85.1 or higher.
- You've requested access to [protected customer data](https://shopify.dev/docs/apps/launch/protected-customer-data#request-access-to-protected-customer-data).
***
## Sample code
The sample code imports API hooks that provide b2b context to customize the checkout.
You can copy and paste the following code into your `index` file and add a few example values to get the extension to render in the browser. The rest of the tutorial walks through this sample code step-by-step.
## src/index.jsx
```jsx
import React from "react";
import {
Banner,
BlockStack,
useCustomer,
useAppMetafields,
usePurchasingCompany,
useCheckoutSettings,
} from "@shopify/ui-extensions-react/checkout";
export function App() {
const metafields = useAppMetafields();
const isHighValueClient = metafields.some(entry =>
entry.target.type === 'company' &&
entry.metafield.key === 'high_value' &&
entry.metafield.value === 'true'
);
const customer = useCustomer();
const checkoutSettings = useCheckoutSettings();
const purchasingCompany = usePurchasingCompany();
// If there isn't a purchasing company, then Shopify handles a D2C buyer checkout.
// In this case, you don't want to render anything.
if(!purchasingCompany) {
return null;
}
if(checkoutSettings.orderSubmission === 'ORDER') {
return null;
}
if(checkoutSettings.orderSubmission === 'DRAFT_ORDER') {
const message = isHighValueClient ?
`${customer.firstName}, even during the holidays we will serve ${purchasingCompany.company.name} promptly, expect the usual turnaround time of 2-3 business days.` :
`Sorry ${customer.firstName}, there will be delays in draft order reviews during this holiday season. Expect a turnaround time of 5-10 business days.`
const status = isHighValueClient ? 'info' : 'warning';
return (
{message}
);
}
return null;
}
```
***
## Step 1: Create a checkout UI extension
Note
If you already have a checkout UI extension that you want to add a custom banner to, then you can skip to [step 2](#step-2-import-components).
To create a checkout UI extension, you can use Shopify CLI, which generates starter code for building your extension and automates common development tasks.
1. Navigate to your app directory:
## Terminal
```terminal
cd
```
2. Run the following command to create a new checkout UI extension:
## Terminal
```terminal
shopify app generate extension --template checkout_ui --name my-checkout-ui-extension
```
3. Select `Checkout UI`.
You should now have a new extension directory in your app's directory. The extension directory includes the extension script at `src/Checkout.jsx`. The following is an example directory structure:
## Checkout UI extension file structure
```text
└── my-app
└── extensions
└── my-checkout-ui-extension
├── src
│ └── Checkout.jsx OR Checkout.js // The index page of the checkout UI extension
├── locales
│ ├── en.default.json // The default locale for the checkout UI extension
│ └── fr.json // The locale file for non-regional French translations
├── shopify.extension.toml // The config file for the checkout UI extension
└── package.json
```
4. Start your development server to build and preview your app:
## Terminal
```terminal
shopify app dev
```
To learn about the processes that are executed when you run `dev`, refer to the [Shopify CLI command reference](https://shopify.dev/docs/api/shopify-cli/app/app-dev).
5. Press `p` to open the developer console. In the developer console page, click on the preview link for your extension.
***
## Step 2: Import components
In the `index` file, import the components from the [Checkout UI extensions API](https://shopify.dev/docs/api/checkout-ui-extensions#ui-components) that you need to build the extension:
##### src/index.jsx
```jsx
import React from "react";
import {
Banner,
BlockStack,
useCustomer,
useAppMetafields,
usePurchasingCompany,
useCheckoutSettings,
} from "@shopify/ui-extensions-react/checkout";
```
##### src/index.js
```js
import {
extension,
Banner,
BlockStack,
} from "@shopify/ui-extensions/checkout";
```
***
## Step 3: Set up the targets
The [`purchase.checkout.block.render`](https://shopify.dev/docs/api/checkout-ui-extensions/latest/apis/extensiontargets) target enables merchants to control where the extension is rendered in checkout. In the following example, the `ORDER_SUMMARY4` placement is used so that the extension appears after the order summary:
##### src/Checkout.jsx
```jsx
// Set up the entry point for the extension
export default reactExtension("purchase.checkout.block.render", () => );
```
##### src/Checkout.js
```js
// Set up the entry point for the extension
export default extension("purchase.checkout.block.render", (root, { metafields, purchasingCompany, checkoutSettings }) => {
// App logic goes here
})
```
Tip
You can adjust where dynamic targets display in checkout by appending `?placement-reference={name}` to the checkout URL that's outputted by Shopify CLI. `{name}` represents a [supported location](https://shopify.dev/docs/api/checkout-ui-extensions/latest/extension-targets-overview#dynamic-extension-targets) for dynamic targets. For example, `?placement-reference=ORDER_SUMMARY4`.
***
## Step 4: Configure the metafields
Now that you've set up extension points, you can make metafields available by configuring [shopify.extension.toml](https://shopify.dev/docs/api/checkout-ui-extensions/checkout/configuration#metafields) to access the `customer`, `company`, `companyLocation` metafields in the extension.
## shopify.extension.toml
```toml
...
# The metafields for the extension
[[extensions.metafields]]
namespace = "custom"
key = "high_value"
...
```
In the following example, the extension reads the merchant configured `company` metafield from [`appMetafields`](https://shopify.dev/docs/api/checkout-ui-extensions/apis/standardapi#properties-propertydetail-appmetafields) to determine whether the company has spent a certain amount of money (`high_value`).
##### src/index.jsx
```jsx
...
export function App() {
// Use the merchant-defined metafields
const metafields = useAppMetafields();
const isHighValueClient = metafields.some(entry =>
entry.target.type === 'company' &&
entry.metafield.key === 'high_value' &&
entry.metafield.value === 'true'
);
...
}
```
##### src/index.js
```js
...
function renderApp(root, { metafields }) {
// Use the merchant-defined metafields
const isHighValueClient = metafields.some(entry =>
entry.target.type === 'company' &&
entry.metafield.key === 'high_value' &&
entry.metafield.value === 'true'
);
...
}
```
***
## Step 5: Identify a business customer
You can use the [`usePurchasingCompany`](https://shopify.dev/docs/api/checkout-ui-extensions/2023-07/react-hooks/buyer-identity/usepurchasingcompany) hook to identify whether a checkout is a B2B checkout. The `usePurchasingCompany` hook enables you to display tailored messages to B2B customers or hide information from D2C customers.
##### src/index.jsx
```jsx
...
function App() {
...
const purchasingCompany = usePurchasingCompany();
if(!purchasingCompany) {
return null;
}
...
// Render the banner
return (
{message}
);
}
```
##### src/index.js
```js
...
function renderApp(root, { purchasingCompany }) {
...
if(!purchasingCompany) {
return null;
}
// Render the banner
const app = root.createComponent(
Banner,
{
"Holiday impacts on draft orders",
status,
},
[message]
);
root.appendChild(app);
}
```
***
## Step 6: Identify a draft order checkout
You can use the [`useCheckoutSettings`](https://shopify.dev/docs/api/checkout-ui-extensions/2023-07/react-hooks/metadata/usecheckoutsettings) hook to identify whether a checkout is a draft order checkout. Draft orders require merchant review, so you can inform the B2B buyers with a customized message about the type of checkout they're on.
##### src/index.jsx
```jsx
...
function App() {
...
const checkoutSettings = useCheckoutSettings();
if(checkoutSettings.orderSubmission === 'ORDER') {
return null;
}
if(checkoutSettings.orderSubmission === 'DRAFT_ORDER') {
const message = isHighValueClient ?
`${customer.firstName}, even during the holidays we will serve ${purchasingCompany.company.name} promptly, expect the usual turnaround time of 2-3 business days.` :
`Sorry ${customer.firstName}, there will be delays in draft order reviews during this holiday season. Expect a turnaround time of 5-10 business days.`
const status = isHighValueClient ? 'info' : 'warning';
...
// Render the banner
return (
{message}
);
}
```
##### src/index.js
```js
...
function renderApp(root, { checkoutSettings, purchasingCompany }) {
...
if(checkoutSettings.orderSubmission === 'ORDER') {
return null;
}
if(checkoutSettings.orderSubmission === 'DRAFT_ORDER') {
const message = isHighValueClient ?
`${customer.firstName}, even during the holidays we will serve ${purchasingCompany.company.name} promptly, expect the usual turnaround time of 2-3 business days.` :
`Sorry ${customer.firstName}, there will be delays in draft order reviews during this holiday season. Expect a turnaround time of 5-10 business days.`
const status = isHighValueClient ? 'info' : 'warning';
// Render the banner
const app = root.createComponent(
Banner,
{
"Holiday impacts on draft orders",
status,
},
[message]
);
root.appendChild(app);
}
```
***
## Step 7: Deploy the UI extension
When you're ready to release your changes to users, you can create and release an [app version](https://shopify.dev/docs/apps/launch/deployment/app-versions). An app version is a snapshot of your app configuration and all extensions.
You can have up to 50 checkout UI extensions in an app version.
1. Navigate to your app directory.
2. Run the following command.
Optionally, you can provide a name or message for the version using the `--version` and `--message` flags.
## Terminal
```terminal
shopify app deploy
```
Releasing an app version replaces the current active version that's served to stores that have your app installed. It might take several minutes for app users to be upgraded to the new version.
Tip
If you want to create a version, but avoid releasing it to users, then run the `deploy` command with a `--no-release` flag. You can release the unreleased app version using Shopify CLI's [`release`](https://shopify.dev/docs/api/shopify-cli/app/app-release) command, or through the Dev Dashboard.
***
## Troubleshooting
This section describes how to solve some potential errors when you run `dev` for an app that contains a checkout UI extension.
### Property token error
If you receive the error `ShopifyCLI:AdminAPI requires the property token to be set`, then you'll need to use the [`--checkout-cart-url` flag](https://shopify.dev/docs/api/shopify-cli/app/app-dev#flags) to direct Shopify CLI to open a checkout session for you.
## Terminal
```terminal
shopify app dev --checkout-cart-url cart/{product_variant_id}:{quantity}
```
### Missing checkout link
If you don't receive the test checkout URL when you run `dev`, then verify the following:
* You have a development store populated with products.
* You're logged in to the correct Partners organization and development store. To verify, check your app info using the following command:
## Terminal
```terminal
shopify app info
```
Otherwise, you can manually create a checkout with the following steps:
1. From your development store's storefront, add some products to your cart.
2. From the cart, click **Checkout**.
3. From directory of the app that contains your extension, run `dev` to preview your app:
## Terminal
```terminal
shopify app dev
```
4. On the checkout page for your store, change the URL by appending the `?dev=https://{tunnel_url}/extensions` query string and reload the page. The `tunnel_url` parameter allows your app to be accessed using a unique HTTPS URL.
You should now see a rendered order note that corresponds to the code in your project template.
***
## Next steps
* Learn about [the components that are available in checkout UI extensions](https://shopify.dev/docs/api/checkout-ui-extensions/components).
* Consult the API reference for [checkout UI targets](https://shopify.dev/docs/api/checkout-ui-extensions/latest/apis/extensiontargets) and their respective types.
***
* [What you'll learn](https://shopify.dev/docs/apps/build/b2b/create-checkout-ui.md#what-youll-learn)
* [Requirements](https://shopify.dev/docs/apps/build/b2b/create-checkout-ui.md#requirements)
* [Sample code](https://shopify.dev/docs/apps/build/b2b/create-checkout-ui.md#sample-code)
* [Step 1: Create a checkout UI extension](https://shopify.dev/docs/apps/build/b2b/create-checkout-ui.md#step-1-create-a-checkout-ui-extension)
* [Step 2: Import components](https://shopify.dev/docs/apps/build/b2b/create-checkout-ui.md#step-2-import-components)
* [Step 3: Set up the targets](https://shopify.dev/docs/apps/build/b2b/create-checkout-ui.md#step-3-set-up-the-targets)
* [Step 4: Configure the metafields](https://shopify.dev/docs/apps/build/b2b/create-checkout-ui.md#step-4-configure-the-metafields)
* [Step 5: Identify a business customer](https://shopify.dev/docs/apps/build/b2b/create-checkout-ui.md#step-5-identify-a-business-customer)
* [Step 6: Identify a draft order checkout](https://shopify.dev/docs/apps/build/b2b/create-checkout-ui.md#step-6-identify-a-draft-order-checkout)
* [Step 7: Deploy the UI extension](https://shopify.dev/docs/apps/build/b2b/create-checkout-ui.md#step-7-deploy-the-ui-extension)
* [Troubleshooting](https://shopify.dev/docs/apps/build/b2b/create-checkout-ui.md#troubleshooting)
* [Next steps](https://shopify.dev/docs/apps/build/b2b/create-checkout-ui.md#next-steps)