Lists the shipping options of one market, for the buyer to pick at checkout. Accessible via lynkow.shippingOptions; store the choice with lynkow.cart.update({ shippingOptionId }).

Requires a publishable key: pass publishableKey to createClient(), or every call throws LynkowError UNAUTHORIZED. With cache: true, responses are cached for 5 minutes.

Access via: lynkow.shippingOptions

Methods

1 method

list

TypeScript
list(options: ShippingOptionsListOptions): Promise<ShippingOptionList>

Lists the active shipping options of one market, lowest position first, without pagination. market is required: an unknown, draft or other site's market returns an empty list. Prices use the VAT rate of country, else the merchant's country. With a locale, each label is translated when possible and the item carries the fallback fields; fallback: false leaves untranslated options out. Throws LynkowError NOT_FOUND when commerce, markets or shipping are off for the site.

Parameter

Type

Description

options

ShippingOptionsListOptions

ShippingOptionsListOptions: the required market (a mkt_... id), country, locale, fallback and fetchOptions.

Returns: Promise<ShippingOptionList>

TypeScript
const { data: options } = await lynkow.shippingOptions.list({
  market: 'mkt_01j9z3k4m5n6p7q8r9s0t1v2w3',
  country: 'BE', // prices at the VAT rate of the buyer's delivery country
  locale: 'fr',
})

// Offer the options, then store the buyer's choice on the cart.
const chosen = options[0]
if (chosen) {
  const cart = await lynkow.cart.update({ shippingOptionId: chosen.id })
  console.log(cart.shippingTotalCents, cart.totalCents)
}