@medusajs/core-flows
Version:
Set of workflow definitions for Medusa
83 lines • 2.67 kB
TypeScript
import { FulfillmentWorkflow } from "@medusajs/framework/types";
/**
* The data to create the shipping options.
*/
export type CreateShippingOptionsWorkflowInput = FulfillmentWorkflow.CreateShippingOptionsWorkflowInput[];
export declare const createShippingOptionsWorkflowId = "create-shipping-options-workflow";
/**
* This workflow creates one or more shipping options. It's used by the
* [Create Shipping Option Admin API Route](https://docs.medusajs.com/api/admin#shipping-options_postshippingoptions).
*
* You can use this workflow within your own customizations or custom workflows, allowing you to
* create shipping options within your custom flows.
*
* @example
* To calculate a shipping option with flat rate prices:
*
* :::note
*
* Learn more about adding rules to the shipping option's prices in the Pricing Module's
* [Price Rules](https://docs.medusajs.com/resources/commerce-modules/pricing/price-rules) documentation.
*
* :::
*
* ```ts
* const { result } = await createShippingOptionsWorkflow(container)
* .run({
* input: [
* {
* name: "Standard Shipping",
* service_zone_id: "serzo_123",
* shipping_profile_id: "sp_123",
* provider_id: "prov_123",
* type: {
* label: "Standard",
* description: "Standard shipping",
* code: "standard"
* },
* price_type: "flat",
* prices: [
* {
* amount: 500,
* currency_code: "usd"
* }
* ]
* }
* ]
* })
* ```
*
* To calculate shipping option with calculated prices, set `price_type` to `calculated` and don't pass a `prices` array:
*
* :::note
*
* You can calculate the shipping option's price for a cart using the [calculateShippingOptionsPricesWorkflow](https://docs.medusajs.com/resources/references/medusa-workflows/calculateShippingOptionsPricesWorkflow).
*
* :::
*
* ```ts
* const { result } = await createShippingOptionsWorkflow(container)
* .run({
* input: [
* {
* name: "Standard Shipping",
* service_zone_id: "serzo_123",
* shipping_profile_id: "sp_123",
* provider_id: "prov_123",
* type: {
* label: "Standard",
* description: "Standard shipping",
* code: "standard"
* },
* price_type: "calculated",
* }
* ]
* })
* ```
*
* @summary
*
* Create shipping options.
*/
export declare const createShippingOptionsWorkflow: import("@medusajs/framework/workflows-sdk").ReturnWorkflow<CreateShippingOptionsWorkflowInput, FulfillmentWorkflow.CreateShippingOptionsWorkflowOutput, []>;
//# sourceMappingURL=create-shipping-options.d.ts.map