> 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/b2b-setup.md).

# B2B Setup

### <mark style="color:red;">1. Add the B2B App to the Relevant Project in ACC</mark>

In **B2B Dynamic Settings**, add a `password` field in the `Shop` configuration:

```json
SHOP={
    "key": "SHOP",
    "value": {
        "url": "{{SHOP_URL}}",
        "shipping_option_slug": "b2b",
        "payment_option_slug": "b2b"
        ...
        "password": "B2B123456", // field to be added
    }
}
```

### <mark style="color:red;">2. Set Environment Value on the Shop Side</mark>

Ensure that the `password` fields match on both sides:

```
B2B_EXTENSION_CONF={"api_url": "https://{B2B_APP_DOMAIN}/api/v1/", "password": "B2B123456"}
```

### <mark style="color:red;">3. Define the Model Schema for User Model on the Shop Side</mark>

Enter this configuration via **COMMERCE API** as it will not reflect on forms within Omnitron screens:

```json
{
  "b2b_token": {
    "key": "b2b_token",
    "label": "B2B Token",
    "data_type": "text"
  },
  "division_erp_code": {
    "key": "division_erp_code",
    "label": "B2B Division ERP Code",
    "data_type": "text"
  }
}
```

### <mark style="color:red;">4. Integrate PromotionGateway for B2B Discounts on the Shop Side</mark>

Set the `offer_priority` to the highest among existing campaigns.

```json
{
  "conf": {
    "klass": "omnishop.promotions.backend.b2b.service.B2BPromotionService",
    "offer_priority": 9999
  },
  "gateway": "b2b",
  "id": 1,
  "is_active": true,
  "name": "b2b"
}
```

### <mark style="color:red;">5. Add a ShippingOption for B2B on the Shop Side</mark>

Ensure the `slug` in the created ShippingOption matches the `shipping_option_slug` in Step 1.

```json
{
  "calculator": {
    "name": "Free Calculator",
    "slug": "free-calculator"
  },
  "delivery_type": "standard",
  "description": null,
  "id": 6,
  "is_active": true,
  "kwargs": {},
  "name": "B2B",
  "rule": {
    "name": "Client Type Rule",
    "slug": "client-type-rule",
    "clients": [
      "b2b"
    ]
  },
  "slug": "b2b"
}
```

### <mark style="color:red;">6. Add a CargoCompany for B2B in Omnitron</mark>

```json
{
    "pk": 67,
    "name": "b2b",
    "erp_code": "b2b",
    "shipping_company": "other",
    "modified_date": "2023-09-01T09:41:10.288813Z",
    "created_date": "2023-09-01T09:41:10.288781Z"
}
```

### <mark style="color:red;">7. Configure PaymentOption for B2B on the Shop Side</mark>

Ensure the `slug` matches the `payment_option_slug` defined in Step 1.

```json
{
  "config": {
    "rule": {
      "klass": "omnishop.payments.rules.B2BPaymentRule",
      "params": {}
    }
  },
  "is_active": true,
  "name": "B2B",
  "payment_type": "b2b",
  "slug": "b2b"
}
```


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
