> ## Documentation Index
> Fetch the complete documentation index at: https://www.twicecommerce.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# How to calculate a skier's DIN setting

> Set up a smart field that sends each skier's checkout answers to the TWICE Commerce DIN calculator and shows the binding release setting on the order.

> [card] [Open in TWICE Admin](https://admin.twicecommerce.com/catalog/listings)
>
> catalog/listings

Set up a DIN field on your ski SKU to show each skier's binding release setting on the order, worked out from what they answered at checkout. The field is a smart field that calls the TWICE Commerce DIN calculator through a connector. [Smart fields](https://www.twicecommerce.com/docs/concepts/admin/smart-fields.md) explains placeholders, when a value is computed and what a failed compute shows.

## Prerequisites

> [!WARNING]
>
> **Required permissions:**
>
> * **Manage integrations and API keys** (`account_settings:integrations:create`) for the API key and the connector.
> * **Manage rules and requirements** (`catalog:listing_checkout_requirements:create`) for the checkout questions.
> * **Create and edit attributes** (`inventory:attribute:create`) and **Create and edit SKUs** (`inventory:sku:manage`) for the field.
>
> Owner and Admin hold all four. Manager does not hold the first, and Member holds neither of the first two. See [Users & Roles](https://www.twicecommerce.com/docs/settings/users-roles.md).

> [!NOTE]
>
> **Have ready before you start:**
>
> * **A ski listing and its SKU**, and boots that customers book on the same order.
> * **The boot sole length in millimetres on your boots**, as a fulfillment field or a stock item attribute. Follow [Add a fulfillment field](https://www.twicecommerce.com/docs/guides/inventory/add-a-fulfillment-field.md) to add one.
> * **The units the calculator reads**: weight in kilograms, height in centimetres, age in years.

> [!NOTE]
>
> The DIN calculator is a TWICE Commerce endpoint that the [API reference](https://www.twicecommerce.com/docs/api-reference) does not list. It reads no data from your account and stores nothing.

## The walkthrough

**1. Ask the skier questions at checkout**

Open the ski listing in **Catalog** and click its **Checkout settings** tab. Click **Add fields** on the **Checkout fields** card and add a **Number field** each for Weight, Height and Age. Add a **Select field** named Skier type with the options Beginner, Intermediate, Advanced and Expert. The **Key** column lists each field's key.

**2. Create an API key**

Open **Settings → Integrations & API** and click **Create key** on the **API keys** card. Enter a name under **API key label** and click **Next**. On the **Access** step, choose **Limited access** with one area at **Read**, then click **Create API key**. Copy the key from **Store your API key**: it is shown once.

**3. Add the connector**

On the same page, click **Add connector** on the **Connectors** card. Choose **API key** under **Authentication** and enter a **Name**, such as DIN calculator. Set **Base URL** to `https://server.twicecommerce.com/internal`, paste the key into **Token** and click **Add connector** at the bottom of the panel.

**4. Start a new field on the ski SKU**

Open **Inventory → SKUs**, click the ski SKU's row and click its **Fulfilment** tab. Click **Add fields** on the **Fulfillment fields** card, then **Create a new attribute…** in the **Add attributes** panel. The **Add new attribute** panel opens over it.

**5. Make it a smart field**

Enter DIN under **Name** and choose **Smart field** under **Type**. The smart field's steps appear below. In the first step, keep **Call an API** selected and pick your connector under **Connector**.

**6. Set the endpoint**

Under **Set the endpoint**, keep **POST** selected and enter `/calculators/din` in **Endpoint path**.

**7. Build the request**

Under **Build the request**, click **Add field** five times and name the rows `weight`, `height`, `age`, `skierType` and `bootSoleLength`, exactly as written. Click **Choose a value** on each row and pick the matching answer under **Customer**. For `bootSoleLength`, pick your boot sole length field under **Customer's items**.

**8. Pick the result**

In the step after the request, enter `din` in **Response path** and choose **Number** under **Output type**.

**9. Save the field and add it to the SKU**

Leave the checkbox under **When to compute** ticked and click **Save** at the bottom of the panel. Then click **Add 1 attribute** at the bottom of the **Add attributes** panel. Both panels close, and DIN is listed on the **Fulfillment fields** card.

**10. Read the setting on an order**

Open an order for the skis and boots in **Orders**, with the checkout questions answered and a stock item assigned to each. On its **Summary** tab, the **Fulfillment details** column shows DIN beside the skis, with the setting filled in.

## How do I know it worked?

* **The order shows a DIN value** beside the skis under **Fulfillment details**, without anyone typing it.
* **Changing an answer changes the value** while the order is **Open** or **In progress**.
* **The calculator answers your key.** Send the request below with your own key and compare the reply.

```bash cURL theme={null}
curl -X POST https://server.twicecommerce.com/internal/calculators/din \
  -H "X-API-KEY: {key}" \
  -H "Content-Type: application/json" \
  -d '{"weight": 75, "height": 175, "age": 20, "bootSoleLength": 300, "skierType": "intermediate"}'
```

```json Response theme={null}
{
  "din": 6.5,
  "skierCode": "L",
  "skierType": 2,
  "skierTypeLabel": "Type 2"
}
```

## Troubleshooting / common pitfalls

> [accordion] The DIN row stays empty on the order
>
> A value is fetched once every input has a value. Check the skier answered all four questions and the boots carry a boot sole length. Then press **Compute value** on the DIN row. See [Smart fields](https://www.twicecommerce.com/docs/concepts/admin/smart-fields.md).

> [accordion] The DIN row shows a warning
>
> Press the warning to read the whole error. The calculator refuses a skier type it does not know, a measurement that is not a number, and a combination the chart has no setting for. A deleted or expired API key fails every compute. See [Smart fields](https://www.twicecommerce.com/docs/concepts/admin/smart-fields.md).

> [accordion] Your skier levels are worded differently
>
> The calculator reads the ISO names `1-`, `1`, `2`, `3` and `3+`, and the levels cautious, beginner, intermediate, advanced and expert. It also reads common Finnish, Swedish and Danish wordings. Rename an option it refuses to one of these.

## Related articles

> [card] [Smart fields](https://www.twicecommerce.com/docs/concepts/admin/smart-fields.md)
>
> Placeholders, when a value is computed, and what a failed compute shows.

> [card] [Integrations & API settings](https://www.twicecommerce.com/docs/settings/integrations.md)
>
> Connectors, API keys and webhooks.

> [card] [API keys](https://www.twicecommerce.com/docs/concepts/integrations/api-keys.md)
>
> Full and limited access, and the areas a key can be given.

> [card] [Checkout settings](https://www.twicecommerce.com/docs/catalog/listings/checkout-settings.md)
>
> The questions a listing asks at checkout.

> [card] [Add a fulfillment field](https://www.twicecommerce.com/docs/guides/inventory/add-a-fulfillment-field.md)
>
> Define a field staff read or fill in on the order.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.