Files
medusa-store/www/apps/docs/content/references/js-client/classes/ShippingOptionsResource.mdx
github-actions[bot] cdd42dbdcd chore(docs): Generated References (#5743)
Generated the following references:
- `entities`
- `inventory`
- `js-client`
- `pricing`
- `product`
- `services`
- `stock-location`
- `workflows`

Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
Co-authored-by: Shahed Nasser <27354907+shahednasser@users.noreply.github.com>
2023-11-27 18:58:52 +00:00

590 lines
22 KiB
Plaintext

---
displayed_sidebar: jsClientSidebar
slug: /references/js-client/ShippingOptionsResource
---
import ParameterTypes from "@site/src/components/ParameterTypes"
# ShippingOptionsResource
This class is used to send requests to [Store Shipping Option API Routes](https://docs.medusajs.com/api/store#shipping-options). 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](https://docs.medusajs.com/modules/carts-and-checkout/shipping#shipping-option).
## Methods
#### list
Retrieve a list of shipping options. The shipping options can be filtered using the `query` parameter.
##### Example
```ts
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
<ParameterTypes parameters={[
{
"name": "query",
"type": "[StoreGetShippingOptionsParams](../internal/classes/internal.StoreGetShippingOptionsParams.mdx)",
"description": "The filters to apply on the shipping options.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "is_return",
"type": "`string`",
"description": "Filter the shipping options by whether they're return shipping options.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "product_ids",
"type": "`string`",
"description": "Product ID that is used to filter shipping options by whether they can be used to ship that product.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "region_id",
"type": "`string`",
"description": "Filter the shipping options by the ID of their associated region.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
}
]
},
{
"name": "customHeaders",
"type": "`Record<string, any>`",
"description": "Custom headers to attach to the request.",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
}
]} />
##### Returns
<ParameterTypes parameters={[
{
"name": "ResponsePromise",
"type": "[ResponsePromise](../internal/types/internal.ResponsePromise.mdx)&#60;[StoreShippingOptionsListRes](../internal/types/internal.StoreShippingOptionsListRes.mdx)&#62;",
"optional": false,
"defaultValue": "",
"description": "Resolves to the list of shipping options.",
"expandable": false,
"children": [
{
"name": "StoreShippingOptionsListRes",
"type": "`object`",
"description": "The list of shipping options.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "shipping_options",
"type": "[PricedShippingOption](../internal/types/internal.PricedShippingOption.mdx)[]",
"description": "An array of shipping options details.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "admin_only",
"type": "`boolean`",
"description": "Flag to indicate if the Shipping Option usage is restricted to admin users.",
"optional": false,
"defaultValue": "false",
"expandable": false,
"children": []
},
{
"name": "amount",
"type": "`null` \\| `number`",
"description": "The amount to charge for shipping when the Shipping Option price type is `flat\\_rate`.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "created_at",
"type": "`Date`",
"description": "The date with timezone at which the resource was created.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "data",
"type": "`Record<string, unknown>`",
"description": "The data needed for the Fulfillment Provider to identify the Shipping Option.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "deleted_at",
"type": "`null` \\| `Date`",
"description": "The date with timezone at which the resource was deleted.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "id",
"type": "`string`",
"description": "The shipping option's ID",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "includes_tax",
"type": "`boolean`",
"description": "Whether the shipping option price include tax",
"optional": false,
"defaultValue": "false",
"expandable": false,
"featureFlag": "tax_inclusive_pricing",
"children": []
},
{
"name": "is_return",
"type": "`boolean`",
"description": "Flag to indicate if the Shipping Option can be used for Return shipments.",
"optional": false,
"defaultValue": "false",
"expandable": false,
"children": []
},
{
"name": "metadata",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "name",
"type": "`string`",
"description": "The name given to the Shipping Option - this may be displayed to the Customer.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "price_type",
"type": "[ShippingOptionPriceType](../internal/enums/internal.internal.ShippingOptionPriceType.mdx)",
"description": "The type of pricing calculation that is used when creatin Shipping Methods from the Shipping Option. Can be `flat\\_rate` for fixed prices or `calculated` if the Fulfillment Provider can provide price calulations.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "profile",
"type": "[ShippingProfile](../internal/classes/internal.ShippingProfile.mdx)",
"description": "The details of the shipping profile that the shipping option belongs to.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "profile_id",
"type": "`string`",
"description": "The ID of the Shipping Profile that the shipping option belongs to.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "provider",
"type": "[FulfillmentProvider](../internal/classes/internal.internal.FulfillmentProvider.mdx)",
"description": "The details of the fulfillment provider that will be used to later to process the shipping method created from this shipping option and its fulfillments.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "provider_id",
"type": "`string`",
"description": "The ID of the fulfillment provider that will be used to later to process the shipping method created from this shipping option and its fulfillments.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "region",
"type": "[Region](../internal/classes/internal.Region.mdx)",
"description": "The details of the region this shipping option can be used in.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "region_id",
"type": "`string`",
"description": "The ID of the region this shipping option can be used in.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "requirements",
"type": "[ShippingOptionRequirement](../internal/classes/internal.internal.ShippingOptionRequirement.mdx)[]",
"description": "The details of the requirements that must be satisfied for the Shipping Option to be available for usage in a Cart.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "updated_at",
"type": "`Date`",
"description": "The date with timezone at which the resource was updated.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "price_incl_tax",
"type": "`number` \\| `null`",
"description": "Price including taxes",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "tax_amount",
"type": "`number`",
"description": "The taxes applied.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "tax_rates",
"type": "[TaxServiceRate](../internal/types/internal.TaxServiceRate.mdx)[] \\| `null`",
"description": "An array of applied tax rates",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]
}
]
}
]
}
]} />
___
#### listCartOptions
Retrieve a list of shipping options available for a cart.
##### Example
```ts
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
<ParameterTypes parameters={[
{
"name": "cart_id",
"type": "`string`",
"description": "The cart's ID.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "customHeaders",
"type": "`Record<string, any>`",
"description": "Custom headers to attach to the request.",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
}
]} />
##### Returns
<ParameterTypes parameters={[
{
"name": "ResponsePromise",
"type": "[ResponsePromise](../internal/types/internal.ResponsePromise.mdx)&#60;[StoreShippingOptionsListRes](../internal/types/internal.StoreShippingOptionsListRes.mdx)&#62;",
"optional": false,
"defaultValue": "",
"description": "Resolves to the list of shipping options.",
"expandable": false,
"children": [
{
"name": "StoreShippingOptionsListRes",
"type": "`object`",
"description": "The list of shipping options.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "shipping_options",
"type": "[PricedShippingOption](../internal/types/internal.PricedShippingOption.mdx)[]",
"description": "An array of shipping options details.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "admin_only",
"type": "`boolean`",
"description": "Flag to indicate if the Shipping Option usage is restricted to admin users.",
"optional": false,
"defaultValue": "false",
"expandable": false,
"children": []
},
{
"name": "amount",
"type": "`null` \\| `number`",
"description": "The amount to charge for shipping when the Shipping Option price type is `flat\\_rate`.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "created_at",
"type": "`Date`",
"description": "The date with timezone at which the resource was created.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "data",
"type": "`Record<string, unknown>`",
"description": "The data needed for the Fulfillment Provider to identify the Shipping Option.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "deleted_at",
"type": "`null` \\| `Date`",
"description": "The date with timezone at which the resource was deleted.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "id",
"type": "`string`",
"description": "The shipping option's ID",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "includes_tax",
"type": "`boolean`",
"description": "Whether the shipping option price include tax",
"optional": false,
"defaultValue": "false",
"expandable": false,
"featureFlag": "tax_inclusive_pricing",
"children": []
},
{
"name": "is_return",
"type": "`boolean`",
"description": "Flag to indicate if the Shipping Option can be used for Return shipments.",
"optional": false,
"defaultValue": "false",
"expandable": false,
"children": []
},
{
"name": "metadata",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "name",
"type": "`string`",
"description": "The name given to the Shipping Option - this may be displayed to the Customer.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "price_type",
"type": "[ShippingOptionPriceType](../internal/enums/internal.internal.ShippingOptionPriceType.mdx)",
"description": "The type of pricing calculation that is used when creatin Shipping Methods from the Shipping Option. Can be `flat\\_rate` for fixed prices or `calculated` if the Fulfillment Provider can provide price calulations.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "profile",
"type": "[ShippingProfile](../internal/classes/internal.ShippingProfile.mdx)",
"description": "The details of the shipping profile that the shipping option belongs to.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "profile_id",
"type": "`string`",
"description": "The ID of the Shipping Profile that the shipping option belongs to.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "provider",
"type": "[FulfillmentProvider](../internal/classes/internal.internal.FulfillmentProvider.mdx)",
"description": "The details of the fulfillment provider that will be used to later to process the shipping method created from this shipping option and its fulfillments.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "provider_id",
"type": "`string`",
"description": "The ID of the fulfillment provider that will be used to later to process the shipping method created from this shipping option and its fulfillments.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "region",
"type": "[Region](../internal/classes/internal.Region.mdx)",
"description": "The details of the region this shipping option can be used in.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "region_id",
"type": "`string`",
"description": "The ID of the region this shipping option can be used in.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "requirements",
"type": "[ShippingOptionRequirement](../internal/classes/internal.internal.ShippingOptionRequirement.mdx)[]",
"description": "The details of the requirements that must be satisfied for the Shipping Option to be available for usage in a Cart.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "updated_at",
"type": "`Date`",
"description": "The date with timezone at which the resource was updated.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "price_incl_tax",
"type": "`number` \\| `null`",
"description": "Price including taxes",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "tax_amount",
"type": "`number`",
"description": "The taxes applied.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "tax_rates",
"type": "[TaxServiceRate](../internal/types/internal.TaxServiceRate.mdx)[] \\| `null`",
"description": "An array of applied tax rates",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]
}
]
}
]
}
]} />