> For the complete documentation index, see [llms.txt](https://docs.akinon.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.akinon.com/technical-guides/b2b/getting-started.md).

# Overview

B2B manages a brand's wholesale sales. Wholesale differs from retail: the brand's divisions (dealers, franchisees, stores) order large quantities, and headquarters reviews and approves every order before it ships. To keep this flow separate from the retail order flow, B2B runs as its own application next to Commerce.

B2B users collect products in a B2B basket and submit the basket as a quotation. A quotation is a draft for a group of orders. After it is approved, B2B creates the orders in Commerce: at least one for each division in the quotation.

## <mark style="color:red;">How B2B Works</mark> <a href="#how-b2b-works" id="how-b2b-works"></a>

B2B works together with three other systems:

| System     | Role                                                                                                                                                                                                                |
| ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Storefront | B2B users shop on the brand's storefront, which has the [B2B plugin](https://docs.akinon.com/technical-guides/project-zero/next.js/plugins/b2b.md). The B2B basket and quotation screens call B2B through Commerce. |
| Commerce   | Forwards the storefront's requests under `/b2b/` to B2B, for signed-in B2B users only. After approval, it receives the orders that B2B creates.                                                                     |
| B2B        | Stores divisions, users, baskets and quotations, and creates the orders.                                                                                                                                            |
| Omnitron   | Headquarters staff manage divisions, users and quotations from the **B2B** menu, and sign in with their Omnitron accounts. B2B reads products, prices, stock and segments from Omnitron.                            |

<figure><img src="https://2911598027-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlQinVPnOffBiOp126ldR%2Fuploads%2Fgit-blob-9eaf9a69f50b434ea0bdc4f75873ea686e5ae922%2Fimage.png?alt=media" alt="The storefront sends /b2b/ requests to Commerce, which forwards them to B2B. B2B reads data from Commerce and creates orders in it." width="375"><figcaption><p>Requests and orders between Commerce and B2B</p></figcaption></figure>

A quotation becomes orders as follows:

1. A B2B user adds products to the B2B basket on the storefront and submits it as a quotation.
2. If the user belongs to a sub-division, the main division approves the quotation first.
3. Headquarters reviews the quotation in Omnitron. It can edit quantities, add a discount, approve the quotation, reject it, or send it back to its owner, who then approves or rejects the edited quotation.
4. When the quotation is approved, B2B splits it into orders: one per division, and more than one when a division orders more than 500 units (the default batch size of the installation).
5. For each order, B2B signs in to Commerce as the quotation owner and completes a checkout with the B2B shipping option and the B2B payment option. Commerce applies the quotation's discount through the B2B promotion gateway.
6. The orders reach Omnitron like any other Commerce order.

To set up these connections, follow **Tutorials > B2B > How to Set Up B2B from Scratch**.

## <mark style="color:red;">Key Concepts</mark> <a href="#key-concepts" id="key-concepts"></a>

### <mark style="color:red;">Divisions</mark> <a href="#divisions" id="divisions"></a>

A division is a business that orders from the brand. A **main** division can have **sub** divisions, for example a dealer and its stores. Each division has a unique ERP code and an address. Orders are delivered to the address of the ordering division.

A main division has a monthly order limit. It is compared with the totals before discount of all quotations created in the current month by the main division and its sub-divisions, whatever their status, plus the new quotation. A quotation that would exceed the limit can't be created.

### <mark style="color:red;">Users and Staff</mark> <a href="#users-and-staff" id="users-and-staff"></a>

B2B users belong to a division. They don't register on the storefront: headquarters staff create them in Omnitron, and B2B creates their Commerce accounts with the same email address and password. Headquarters staff don't need B2B users, because they sign in to the B2B screens with their Omnitron accounts.

### <mark style="color:red;">Baskets and Segments</mark> <a href="#baskets-and-segments" id="baskets-and-segments"></a>

B2B keeps a separate basket for each [segment](https://docs.akinon.com/technical-guides/commerce/configuring-user-segmentation.md). When a B2B user switches to another segment on the storefront, they see the basket and the prices of that segment. A user can also save a basket as a draft and load it later.

### <mark style="color:red;">Assortment Packs</mark> <a href="#assortment-packs" id="assortment-packs"></a>

In wholesale, a style is often sold only in assortment packs, also called prepacks or lots: a fixed mix of sizes sold as one unit, for example one S, two M and two L. The buyer orders packs, not single sizes.

Akinon builds assortment packs with the standard product structure. Each pack is a separate product (SKU) with its own price and stock, and the assortment type is a variant attribute that the buyer selects on the product page like a size. In B2B, the quantity of a pack is the number of packs, and the order reaches the ERP with the pack SKU. B2B doesn't check the size breakdown of a pack.

To set up assortment packs, follow **Tutorials > B2B > How to Sell Assortment Packs in B2B**.

## <mark style="color:red;">Example: From Quotation to Orders</mark> <a href="#example-from-quotation-to-orders" id="example-from-quotation-to-orders"></a>

The following quotation contains products for two divisions:

| Product | Division   | Quantity |
| ------- | ---------- | -------- |
| SKU01   | Division A | 30       |
| SKU01   | Division B | 20       |
| SKU02   | Division A | 10       |

When it is approved, B2B creates two orders, one for each division:

| Order               | Product | Quantity |
| ------------------- | ------- | -------- |
| Order of Division A | SKU01   | 30       |
| Order of Division A | SKU02   | 10       |
| Order of Division B | SKU01   | 20       |

## <mark style="color:red;">Quotation Statuses</mark> <a href="#quotation-statuses" id="quotation-statuses"></a>

| Status                     | Meaning                                                                                                                                      |
| -------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
| `request_approval`         | Created by a sub-division user and waiting for the approval of the main division.                                                            |
| `pending`                  | Waiting for headquarters. Quotations of main divisions start here.                                                                           |
| `draft`                    | Being edited by headquarters.                                                                                                                |
| `sending_approval_request` | Edited by headquarters and waiting for the approval of its owner.                                                                            |
| `approved`                 | Approved by headquarters, or by its owner after headquarters edited it. B2B creates the orders. Omnitron shows this status as **Confirmed**. |
| `rejected`                 | Rejected by headquarters, by the main division, or by its owner after headquarters edited it.                                                |
| `cancelled`                | Cancelled by its owner.                                                                                                                      |
| `expired`                  | Expired. B2B doesn't set this status automatically.                                                                                          |

Whether sub-division quotations need the approval of the main division depends on the [`IS_SUB_DIVISION_QUOTATION_APPROVAL_REQUIRED`](https://docs.akinon.com/pages/UNJjlWf2Aosk6sU0ZVi7#id-3.-sub-division-quotation-approval) setting.

## <mark style="color:red;">Order Statuses</mark> <a href="#order-statuses" id="order-statuses"></a>

After approval, B2B creates the orders of a quotation in Commerce one at a time.

| Status    | Meaning                                                                                                                                                                          |
| --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `pending` | Waiting to be created.                                                                                                                                                           |
| `created` | Created in Commerce. The order number is shown on the order.                                                                                                                     |
| `failed`  | Couldn't be created. The failure reason is shown on the order. B2B retries failed orders automatically, and staff can retry right away with **Recreate Order** on the quotation. |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.akinon.com/technical-guides/b2b/getting-started.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
