Skip to main content
Skip to main content

ShippingOptionsResource

This class is used to send requests to Store Shipping Option API Routes. All its method are available in the JS Client under the medusa.shippingOptions property.

A shipping option is used to define the available shipping methods during checkout or when creating a return.

Related Guide: Shipping Option architecture.

Methods

listCartOptions

Retrieve a list of shipping options available for a cart.

Example

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.shippingOptions.listCartOptions(cartId)
.then(({ shipping_options }) => {
console.log(shipping_options.length);
})

Parameters

cart_idstringRequired
The cart's ID.
customHeadersRecord<string, any>Required
Custom headers to attach to the request.

Default: {}

Returns

ResponsePromiseResponsePromise<StoreShippingOptionsListRes>Required
Resolves to the list of shipping options.

list

Retrieve a list of shipping options. The shipping options can be filtered using the query parameter.

Example

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.shippingOptions.list()
.then(({ shipping_options }) => {
console.log(shipping_options.length);
})

Parameters

customHeadersRecord<string, any>Required
Custom headers to attach to the request.

Default: {}

The filters to apply on the shipping options.

Returns

ResponsePromiseResponsePromise<StoreShippingOptionsListRes>Required
Resolves to the list of shipping options.
Was this section helpful?