AdminShippingOptionsResource
This class is used to send requests to Admin Shipping Option API Routes. All its method
are available in the JS Client under the medusa.admin.shippingOptions
property.
All methods in this class require user authentication.
A shipping option is used to define the available shipping methods during checkout or when creating a return. Admins can create an unlimited number of shipping options, each associated with a shipping profile and fulfillment provider, among other resources.
Related Guide: Shipping Option architecture.
Methods
create
Create a shipping option.
Example
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.shippingOptions.create({
name: "PostFake",
region_id,
provider_id,
data: {
},
price_type: "flat_rate"
})
.then(({ shipping_option }) => {
console.log(shipping_option.id)
})
Parameters
The shipping option to create.
customHeaders
Record<string, any>RequiredDefault: {}
Returns
ResponsePromise
ResponsePromise<AdminShippingOptionsRes>RequiredResolves to the shipping option's details.
ResponsePromise
ResponsePromise<AdminShippingOptionsRes>Requiredupdate
Update a shipping option's details.
Example
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.shippingOptions.update(optionId, {
name: "PostFake",
requirements: [
{
id,
type: "max_subtotal",
amount: 1000
}
]
})
.then(({ shipping_option }) => {
console.log(shipping_option.id)
})
Parameters
id
stringRequiredThe attributes to update in the shipping option.
customHeaders
Record<string, any>RequiredDefault: {}
Returns
ResponsePromise
ResponsePromise<AdminShippingOptionsRes>RequiredResolves to the shipping option's details.
ResponsePromise
ResponsePromise<AdminShippingOptionsRes>Requireddelete
Delete a shipping option. Once deleted, it can't be used when creating orders or returns.
Example
Parameters
id
stringRequiredcustomHeaders
Record<string, any>RequiredDefault: {}
Returns
ResponsePromise
ResponsePromise<DeleteResponse>RequiredResolves to the deletion operation's details.
ResponsePromise
ResponsePromise<DeleteResponse>Requiredretrieve
Retrieve a shipping option's details.
Example
Parameters
id
stringRequiredcustomHeaders
Record<string, any>RequiredDefault: {}
Returns
ResponsePromise
ResponsePromise<AdminShippingOptionsRes>RequiredResolves to the shipping option's details.
ResponsePromise
ResponsePromise<AdminShippingOptionsRes>Requiredlist
Retrieve a list of shipping options. The shipping options can be filtered by fields such as region_id
or is_return
passed in the query
parameter.
Example
Parameters
customHeaders
Record<string, any>RequiredDefault: {}
Filters to apply on the retrieved shipping options.
Returns
ResponsePromise
ResponsePromise<AdminShippingOptionsListRes>RequiredResolves to the list of shipping options.
ResponsePromise
ResponsePromise<AdminShippingOptionsListRes>Required