shippingOption - JS SDK Admin Reference
This documentation provides a reference to the sdk.admin.shippingOption
set of methods used to send requests to Medusa's Admin API routes.
create#
This method creates a shipping option. It sends a request to the
Create Shipping Option
API route.
Example#
1sdk.admin.shippingOption.create({2 name: "Standard Shipping",3 profile_id: "shp_123",4})5.then(({ shipping_option }) => {6 console.log(shipping_option)7})
Parameters#
The details of the shipping option to create.
Configure the fields and relations to retrieve in the shipping option.
Returns#
The shipping option's details.
retrieve#
This method retrieves a shipping option. It sends a request to the
Get Shipping Option
API route.
Example#
To retrieve a shipping option by its ID:
1sdk.admin.shippingOption.retrieve("so_123")2.then(({ shipping_option }) => {3 console.log(shipping_option)4})
To specify the fields and relations to retrieve:
1sdk.admin.shippingOption.retrieve("so_123", {2 fields: "id,*service_zone"3})4.then(({ shipping_option }) => {5 console.log(shipping_option)6})
Learn more about the fields
property in the API reference.
Parameters#
The ID of the shipping option to retrieve.
Configure the fields and relations to retrieve in the shipping option.
Returns#
The shipping option's details.
update#
This method updates a shipping option. It sends a request to the
Update Shipping Option
API route.
Example#
1sdk.admin.shippingOption.update("so_123", {2 name: "Standard Shipping",3})4.then(({ shipping_option }) => {5 console.log(shipping_option)6})
Parameters#
The ID of the shipping option to update.
The details of the shipping option to update.
Configure the fields and relations to retrieve in the shipping option.
Returns#
The shipping option's details.
delete#
This method deletes a shipping option. It sends a request to the
Delete Shipping Option
API route.
Example#
1sdk.admin.shippingOption.delete("so_123")2.then(({ deleted }) => {3 console.log(deleted)4})
Parameters#
The ID of the shipping option to delete.
Returns#
list#
This method retrieves a list of shipping options. It sends a request to the
List Shipping Options
API route.
Example#
To retrieve the list of shipping options:
1sdk.admin.shippingOption.list()2.then(({ shipping_options, count, limit, offset }) => {3 console.log(shipping_options)4})
To configure the pagination, pass the limit
and offset
query parameters.
For example, to retrieve only 10 items and skip 10 items:
1sdk.admin.shippingOption.list({2 limit: 10,3 offset: 104})5.then(({ shipping_options, count, limit, offset }) => {6 console.log(shipping_options)7})
Using the fields
query parameter, you can specify the fields and relations to retrieve
in each shipping option:
1sdk.admin.shippingOption.list({2 fields: "id,*service_zone"3})4.then(({ shipping_options, count, limit, offset }) => {5 console.log(shipping_options)6})
Learn more about the fields
property in the API reference.
Parameters#
Filters and pagination configurations.
Returns#
The list of shipping options.
updateRules#
This method manages the rules of a shipping option to create, update, or remove them. It sends a request to the
Manage Rules of a Shipping Option
API route.
Example#
1sdk.admin.shippingOption.updateRules("so_123", {2 create: [{ attribute: "enabled_in_store", operator: "eq", value: "true" }],3})4.then(({ shipping_option }) => {5 console.log(shipping_option)6})
Parameters#
The ID of the shipping option to manage the rules for.
The details of the shipping option rules to manage.
Returns#
The shipping option's details.