Skip to main content

Open in TWICE Admin

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 explains placeholders, when a value is computed and what a failed compute shows.

Prerequisites

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.
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 to add one.
  • The units the calculator reads: weight in kilograms, height in centimetres, age in years.
The DIN calculator is a TWICE Commerce endpoint that the 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.

Troubleshooting / common pitfalls

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.
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.
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.

Smart fields

Placeholders, when a value is computed, and what a failed compute shows.

Integrations & API settings

Connectors, API keys and webhooks.

API keys

Full and limited access, and the areas a key can be given.

Checkout settings

The questions a listing asks at checkout.

Add a fulfillment field

Define a field staff read or fill in on the order.