This documentation provides a reference to the createOrderEditShippingMethodWorkflow
. It belongs to the @medusajs/medusa/core-flows
package.
This workflow creates a shipping method for an order edit. It's used by the Add Shipping Method API Route.
You can use this workflow within your customizations or your own custom workflows, allowing you to create a shipping method for an order edit in your in your own custom flows.
Source CodeWorkflow hook
Step conditioned by when
View step details
CreateOrderEditShippingMethodWorkflowInput & AdditionalData
CreateOrderEditShippingMethodWorkflowInput & AdditionalDataCreateOrderEditShippingMethodWorkflowInput
objectAdditionalData
objectadditional_data
property accepted in HTTP
requests, that allows passing custom data and handle them in hooks.
Learn more in this documentation.OrderPreviewDTO
OrderPreviewDTOid
stringversion
numberdisplay_id
numberstatus
OrderStatuscurrency_code
stringcreated_at
string | Dateupdated_at
string | Dateoriginal_item_total
BigNumberValueoriginal_item_subtotal
BigNumberValueoriginal_item_tax_total
BigNumberValueitem_total
BigNumberValueitem_subtotal
BigNumberValueitem_tax_total
BigNumberValueoriginal_total
BigNumberValueoriginal_subtotal
BigNumberValueoriginal_tax_total
BigNumberValuetotal
BigNumberValuesubtotal
BigNumberValuetax_total
BigNumberValuediscount_subtotal
BigNumberValuediscount_total
BigNumberValuediscount_tax_total
BigNumberValuegift_card_total
BigNumberValuegift_card_tax_total
BigNumberValueshipping_total
BigNumberValueshipping_subtotal
BigNumberValueshipping_tax_total
BigNumberValueoriginal_shipping_total
BigNumberValueoriginal_shipping_subtotal
BigNumberValueoriginal_shipping_tax_total
BigNumberValueraw_original_item_total
BigNumberRawValueraw_original_item_subtotal
BigNumberRawValueraw_original_item_tax_total
BigNumberRawValueraw_item_total
BigNumberRawValueraw_item_subtotal
BigNumberRawValueraw_item_tax_total
BigNumberRawValueraw_original_total
BigNumberRawValueraw_original_subtotal
BigNumberRawValueraw_original_tax_total
BigNumberRawValueraw_total
BigNumberRawValueraw_subtotal
BigNumberRawValueraw_tax_total
BigNumberRawValueraw_discount_total
BigNumberRawValueraw_discount_tax_total
BigNumberRawValueraw_gift_card_total
BigNumberRawValueraw_gift_card_tax_total
BigNumberRawValueraw_shipping_total
BigNumberRawValueraw_shipping_subtotal
BigNumberRawValueraw_shipping_tax_total
BigNumberRawValueraw_original_shipping_total
BigNumberRawValueraw_original_shipping_subtotal
BigNumberRawValueraw_original_shipping_tax_total
BigNumberRawValueorder_change
OrderChangeDTOitems
OrderLineItemDTO & object[]shipping_methods
OrderShippingMethodDTO & object[]return_requested_total
numberregion_id
stringOptionalcustomer_id
stringOptionalsales_channel_id
stringOptionalemail
stringOptionalis_draft_order
booleanOptionalmetadata
null | Record<string, unknown>Optionalcanceled_at
string | DateOptionalHooks allow you to inject custom functionalities into the workflow. You'll receive data from the workflow, as well as additional data sent through an HTTP request.
Learn more about Hooks and Additional Data.
This hook is executed before the shipping method is created. You can consume this hook to return any custom context useful for the prices retrieval of the shipping method's option.
For example, assuming you have the following custom pricing rule:
You can consume the setPricingContext
hook to add the location_id
context to the prices calculation:
1import { createOrderEditShippingMethodWorkflow } from "@medusajs/medusa/core-flows";2import { StepResponse } from "@medusajs/workflows-sdk";3 4createOrderEditShippingMethodWorkflow.hooks.setPricingContext((5 { order, shipping_option_id, additional_data }, { container }6) => {7 return new StepResponse({8 location_id: "sloc_123", // Special price for in-store purchases9 });10});
The price of the shipping method's option will now be retrieved using the context you return.
Handlers consuming this hook accept the following input.
input
inputorder
OrderDTOshipping_option_id
stringadditional_data
Record<string, unknown> | undefinedadditional_data
property in HTTP requests.
Learn more in this documentation.