> For the complete Lynkow documentation index in agent-friendly format, see [llms.txt](/llms.txt).

# Markets, Shipping and VAT

**Published**: 2026-11-30
**Category**: Features

> Take a cart from the buyer's country to a placed order: markets, delivery or pickup, shipping options, pickup points, VAT figures and a confirmed total. Previous: [Guide 20](/docs/sdk/features/commerce-customer-accounts) | Next: [Guide 24](/docs/sdk/features/commerce-cart-checkout)

> **Reference** - This guide is a tutorial. For exhaustive, always-current signatures and field lists, see the auto-generated reference:
> 
> - SDK: [`MarketsService`](/docs/sdk/services/sdk-markets-service), [`ShippingOptionsService`](/docs/sdk/services/sdk-shipping-options-service), [`PickupPointsService`](/docs/sdk/services/sdk-pickup-points-service), [`CartService`](/docs/sdk/services/sdk-cart-service), [`CheckoutService`](/docs/sdk/services/sdk-checkout-service)
> - Types: [SDK Types](/docs/sdk/types)
> - API: [Storefront: Commerce](/docs/storefront-api/storefront-commerce)

## Prerequisites

- A client created with a publishable key ([Guide 18](/docs/sdk/features/commerce-products)). Every call in this guide requires one.
- A cart with at least one line ([Guide 24](/docs/sdk/features/commerce-cart-checkout)).
- Markets, shipping options and taxes set up by the merchant under **Settings > E-commerce > Markets**.

## The flow

1. Read the markets and the countries checkout accepts, to build the country picker.
2. Store the buyer's delivery address on the cart.
3. List the shipping options of that country's market, and store the buyer's choice on the cart.
4. When that option delivers to a pickup point, search the points near the buyer and store the one they choose.
5. Show the cart's figures.
6. Place the order with the same address and the total the buyer saw.

A pickup order, which the buyer collects from the merchant, skips steps 2 to 4.

All amounts are integers in the minor unit of the site's currency (cents for EUR), in `cart.currency`.

## Markets

```typescript
// Market (partial): { id, countries, defaultLocale }
const { data: markets, meta } = await lynkow.markets.list()

const market = markets.find((m) => m.countries.includes('FR'))
const countries = meta?.checkoutCountries ?? null
```

A market is a group of countries the merchant sells into, with its languages (`locales`, `defaultLocale`) and the site's currency. `list()` returns the active markets, oldest first. A country belongs to at most one market, so `find()` returns one market or none. The call throws `NOT_FOUND` when markets are not enabled on the site.

The API never picks a market for a visitor: it reads no cookie and no location header. Your storefront picks it from the country the buyer chose, then passes `market.id` to the catalogue reads ([Guide 18](/docs/sdk/features/commerce-products)) and to `shippingOptions.list()`.

### The country picker

Build the picker from `meta.checkoutCountries`, the delivery countries checkout accepts now, as sorted ISO 3166-1 alpha-2 codes:

| Value | Meaning |
| --- | --- |
| `null` | Any country. Offer your own list. |
| `['BE', 'FR', 'LU']` | Only these: the countries of the active markets, or the EU countries when the site computes VAT and has no active market. |
| `[]` | No delivery country, for example when prices are entered without VAT and the site cannot compute VAT. |


`meta` is typed optional only so that a hand-built `MarketList` can omit it. The API always sends it.

## Delivery or pickup

`fulfillmentMode` on `placeOrder()` says how the order reaches the buyer:

- `'delivery'` (the default): the order ships to `address`, or to the pickup point stored on the cart. On a site with active markets, the country must belong to one and every line must be sold there. Shipping applies, and the delivery country decides the VAT.
- `'pickup'`: the buyer collects the order from the merchant. Checkout skips the market checks and charges no shipping. VAT, when computed, is at the merchant country's rate.

For a pickup, clear the delivery address and the shipping choice on the cart first, so the cart shows what the order charges:

```typescript
const cart = await lynkow.cart.update({ deliveryAddress: null, shippingOptionId: null })

const order = await lynkow.checkout.placeOrder({
  email: 'alice@example.com',
  fulfillmentMode: 'pickup',
  paymentMethod: 'click_and_collect',
  expectedTotalCents: cart.totalCents,
  acceptsTerms: true,
})
```

## Shipping

### Store the delivery address

```typescript
import type { OrderAddress } from 'lynkow'

const address: OrderAddress = {
  firstName: 'Alice',
  lastName: 'Martin',
  address1: '12 rue de la Paix',
  city: 'Paris',
  postalCode: '75002',
  countryCode: 'FR',
}

let cart = await lynkow.cart.update({ deliveryAddress: address })
```

`cart.update()` sends only the keys you pass: an absent key keeps the stored value, `null` clears it, and a new address replaces the stored one whole. It returns the cart with recomputed totals. The address's `countryCode` decides which market's shipping options apply and which country's VAT the figures show. An invalid `countryCode` throws `VALIDATION_ERROR`.

### List the shipping options

```typescript
// Each option (partial): { id, label, priceCents }
const { data: options } = market
  ? await lynkow.shippingOptions.list({ market: market.id, country: 'FR', locale: 'fr' })
  : { data: [] }
```

`market` is required. `list()` returns that market's active options in the merchant's order, with `label` in the requested locale when translated. `country` prices the options at that country's VAT rate. Each option carries `priceNetCents`, `priceGrossCents` and `priceDisplayMode`, like a product. An unknown or draft market id lists nothing. The call throws `NOT_FOUND` when shipping is not enabled on the site.

An empty list means the market has no active option. When the site ships to other markets, checkout then refuses delivery to that country with `SHIPPING_UNAVAILABLE`. When the site ships nowhere, a delivery order is charged no shipping.

### Store the buyer's choice

```typescript
cart = await lynkow.cart.update({ shippingOptionId: selectedOptionId }) // a shp_... id

if (cart.shippingOptionId === null) {
  // Not kept: list the options again and ask the buyer to pick.
}
```

The cart keeps a choice only while it is an active option of the delivery country's market. Any other choice is cleared, never refused: an option of another market, a choice made before the cart has a country, or one a new address moves out of its market. The cart then reads `shippingOptionId: null` and `shippingTotalCents: 0`. Set the address first, or both in one call, and read `shippingOptionId` back after every cart call.

### Deliver to a pickup point

```typescript
// PickupPoint (partial): { id, name, address, distanceMeters, openingHours }
const option = options.find((o) => o.id === cart.shippingOptionId)

if (option?.requiresPickupPoint === true) {
  const { data: points } = await lynkow.pickupPoints.search({
    shippingOptionId: option.id,
    countryCode: 'FR',
    postalCode: '75002',
  })
  // Show the points, then store the one the buyer picks.
  cart = await lynkow.cart.update({ pickupPointId: chosenPointId })
}
```

An option with `requiresPickupPoint: true` delivers to a pickup point: a shop or locker where the carrier leaves the parcel for the buyer. Read the flag as `option.requiresPickupPoint === true`. `deliveryLabelKey`, `'home_delivery'` or `'pickup_point_delivery'`, is a stable key to map to your own wording.

`search()` takes the option and `countryCode`, then either `postalCode` or both `latitude` and `longitude`. It returns the points nearest first, 10 by default and up to 30 with `limit`, not paginated. `data` is empty when no point is near. It throws:

- `NOT_FOUND` when pickup points are not enabled on the site.
- `VALIDATION_ERROR` with `apiCode` `SHIPPING_OPTION_NO_PICKUP_POINTS` for an option that takes no point, or `SHIPPING_OPTION_INVALID` for an unknown or inactive one.
- `SERVICE_UNAVAILABLE` with `apiCode` `PICKUP_POINT_SEARCH_UNAVAILABLE` when the points cannot be listed right now. Ask the buyer to try again, or to choose another option.

Each buyer can search 60 times a minute. From your server, all buyers share that count unless you forward their IP ([Guide 26](/docs/sdk/advanced/server-key-buyer-ip)).

`cart.update({ pickupPointId })` stores the point. Set the address and the option first. A refused call writes nothing:

| `apiCode` | When |
| --- | --- |
| `SHIPPING_OPTION_NO_PICKUP_POINTS` | The cart has no delivery country or no option, or its option takes no point. |
| `PICKUP_POINT_INVALID` | The point is unknown or closed. |
| `PICKUP_POINT_SEARCH_UNAVAILABLE` | The point cannot be checked right now. Try again. |


`cart.pickupPoint` then holds the point, with its `id`, `name` and `address`, or `null`. A new shipping option clears it unless the same call sends a point. A delivery country other than the point's clears it too, and so does an option that stops taking a point. Read `pickupPoint` back after every cart call, as you do `shippingOptionId`.

Checkout freezes the point on the order. Send the buyer's address as for any delivery: checkout reads the market, the shipping and the VAT from it, and the point must be in its country. Order reads return the point as `order.pickupPoint`, and the parcels as `order.shipments`, each with its `status` and `trackingUrl`.

## VAT

When the site computes VAT, every amount the cart and the order charge includes it. Every buyer pays the merchant country's rate, unless the merchant turns on One-Stop Shop (OSS): the delivery country's rate then applies, so the figures can change with the address. A site that computes VAT delivers inside the EU only: checkout refuses another destination with `DESTINATION_NOT_TAXABLE`.

### VAT on the cart

```tsx
import type { Cart } from 'lynkow'

function CartTotals({ cart }: { cart: Cart }) {
  const format = (cents: number) => `${(cents / 100).toFixed(2)} ${cart.currency}`

  if (cart.priceDisplayMode === 'exclusive') {
    return (
      <dl>
        <dt>Total excl. VAT</dt><dd>{format(cart.totalCents - cart.taxTotalCents)}</dd>
        <dt>VAT</dt><dd>{format(cart.taxTotalCents)}</dd>
        <dt>Total</dt><dd>{format(cart.totalCents)}</dd>
      </dl>
    )
  }

  return (
    <dl>
      <dt>Subtotal</dt><dd>{format(cart.subtotalCents)}</dd>
      <dt>Shipping</dt><dd>{format(cart.shippingTotalCents)}</dd>
      <dt>Total</dt><dd>{format(cart.totalCents)}</dd>
      <dt>Including VAT</dt><dd>{format(cart.taxTotalCents)}</dd>
    </dl>
  )
}
```

- `totalCents` is `subtotalCents` plus `shippingTotalCents`, both VAT included. `taxTotalCents` is the VAT inside the total: never add it.
- Each line carries `netCents` and `grossCents`. A line's `unitPriceCents` and `subtotalCents` are gross.
- `priceDisplayMode` is display only. The buyer always pays `totalCents`.
- When the site computes no VAT, `taxTotalCents` is 0 and every net amount equals its gross.

The cart computes its VAT for the delivery country, else the merchant's country. To preview a buyer's VAT before they enter an address, pass `country`:

```typescript
const preview = await lynkow.cart.retrieve({ country: 'DE' })
```

`country` affects that response only, never the stored cart, and is ignored once the address has a `countryCode`. An invalid code throws `VALIDATION_ERROR`.

### VAT on the order

```typescript
// Order (partial): { vatTreatment, taxTotalCents, items, shippingLine }
const order = await lynkow.customers.order(orderId)

if (order.vatTreatment === 'charged') {
  for (const item of order.items) {
    console.log(item.buyerTitle ?? item.title, item.taxRateBp, item.taxCents)
  }
  console.log('Shipping VAT', order.shippingLine?.taxCents ?? 0)
}
```

VAT is frozen on the order when it is placed:

- `vatTreatment` is `'charged'` or `'not_computed'`. With `'not_computed'`, `taxTotalCents` is 0 and every rate is `null`.
- Rates are basis points: `2000` is 20%. Each line's `taxCents` is the VAT its `subtotalCents` contains.
- `shippingLine` is `{ name, amountCents, taxRateBp, taxCents }`, or `null` when no shipping applied.
- `taxTotalCents` sums the lines' and the shipping line's `taxCents`, and is part of `totalCents`.

Every order read returns this shape ([Guide 20](/docs/sdk/features/commerce-customer-accounts)). On the `placeOrder()` result only, `shippingLine` can be absent: read the order again to get it.

## Place the order

```typescript
import { isLynkowError } from 'lynkow'

try {
  const order = await lynkow.checkout.placeOrder({
    email: 'alice@example.com',
    address, // the address stored on the cart
    fulfillmentMode: 'delivery',
    expectedTotalCents: cart.totalCents, // the total the buyer saw
    acceptsTerms: true,
  })
} catch (error) {
  if (isLynkowError(error) && error.apiCode === 'TOTAL_CHANGED') {
    const fresh = await lynkow.cart.retrieve()
    showTotal(fresh.totalCents) // show the new total and ask the buyer to confirm again
  } else {
    throw error
  }
}
```

- Checkout reads the market, the shipping and the VAT from the `address` it receives, never from the cart. Send the address the cart holds.
- `shippingOptionId` defaults to the cart's choice. Omit it unless you want to override that choice.
- The pickup point always comes from the cart: `placeOrder()` takes none.
- When the computed total differs from `expectedTotalCents`, checkout refuses with `TOTAL_CHANGED` and creates nothing. The error carries no amount: read the cart again. Without `expectedTotalCents`, checkout compares nothing, so send it from every confirmation page.

### Checkout refusals

Each refusal is a `LynkowError` with `code` `VALIDATION_ERROR` (HTTP 422), the reason in `error.apiCode` and the field, when there is one, in `error.details?.[0]?.field`. A refusal creates no order and leaves the cart open.

| `apiCode` | `field` | When | What to do |
| --- | --- | --- | --- |
| `DELIVERY_COUNTRY_REQUIRED` | `address.countryCode` | A delivery order has no country, on a site with markets or VAT. | Ask for the country. |
| `MARKET_COUNTRY_NOT_SERVED` | `address.countryCode` | The country is in no active market. | Offer `checkoutCountries` only. |
| `PRODUCT_NOT_SOLD_IN_MARKET` | none | An item is not sold in that market. | Tell the buyer which item cannot ship there. |
| `SHIPPING_OPTION_INVALID` | `shippingOptionId` | The market has options and none of them is chosen. | List the options again. |
| `SHIPPING_UNAVAILABLE` | `address.countryCode` | The market has no option while other markets do. | Offer another country, or pickup. |
| `PICKUP_POINT_REQUIRED` | `pickupPointId` | The shipping option delivers to a pickup point and the cart holds none. | Ask the buyer to choose a point. |
| `PICKUP_POINT_INVALID` | `pickupPointId` | The point is closed, unknown, or outside the delivery country. | Search again and ask for another point. |
| `TOTAL_CHANGED` | `expectedTotalCents` | The total moved. | Show the new total and ask again. |
| `DESTINATION_NOT_TAXABLE` | `address.countryCode` | The site computes VAT and the country is outside the EU. | Offer `checkoutCountries` only. |
| `TAX_RATE_UNAVAILABLE` | none | No VAT rate can price the order. | Show a generic error. |
| `CHECKOUT_TAX_DISABLED` | none | Prices are entered without VAT and the site cannot compute VAT. | Show a generic error: checkout stays closed and the buyer cannot fix it. |
| `OUT_OF_STOCK` | none | A line exceeds the stock left, on a site that refuses overselling. | Read the cart again. |


A pickup order, collected from the merchant, skips the market, shipping, pickup point and destination checks. The `pickupPointId` field names the cart input that fixes the refusal. The terms and payment refusals are in [Guide 24](/docs/sdk/features/commerce-cart-checkout).

## Next Steps

- [Guide 24: Cart and Checkout](/docs/sdk/features/commerce-cart-checkout) - wire the cart and checkout into a Next.js storefront.
- [Guide 20: Customer Accounts](/docs/sdk/features/commerce-customer-accounts) - order history and the guest order page.
- [Guide 12: Error Handling](/docs/sdk/advanced/error-handling) - `LynkowError` and how to branch on it.