updateExchangeShippingMethodWorkflow - Medusa Core Workflows Reference

This documentation provides a reference to the updateExchangeShippingMethodWorkflow. It belongs to the @medusajs/medusa/core-flows package.

This workflow updates an exchange's inbound or outbound shipping method. It's used by the Update Inbound Shipping Admin API Route or the Outbound Inbound Shipping Admin API Route.

You can use this workflow within your customizations or your own custom workflows, allowing you to update an exchange's inbound or outbound shipping method in your custom flow.

Source Code

Examples#

Steps#

Input#

UpdateExchangeShippingMethodWorkflowInput & AdditionalDataUpdateExchangeShippingMethodWorkflowInput & AdditionalData
UpdateExchangeShippingMethodWorkflowInputobject
The details of the shipping method to be updated in the exchange.
AdditionalDataobject
Additional data, passed through the additional_data property accepted in HTTP requests, that allows passing custom data and handle them in hooks. Learn more in this documentation.

Output#

OrderPreviewDTOOrderPreviewDTO
The details of an order after a change is applied on it.
idstring
The ID of the order.
versionnumber
The version of the order.
display_idnumber
The order's display ID.
The status of the order.
currency_codestring
The currency of the order
created_atstring | Date
When the order was created.
updated_atstring | Date
When the order was updated.
original_item_totalBigNumberValue
The original item total of the order.
original_item_subtotalBigNumberValue
The original item subtotal of the order.
original_item_tax_totalBigNumberValue
The original item tax total of the order.
item_totalBigNumberValue
The item total of the order.
item_subtotalBigNumberValue
The item subtotal of the order.
item_tax_totalBigNumberValue
The item tax total of the order.
original_totalBigNumberValue
The original total of the order.
original_subtotalBigNumberValue
The original subtotal of the order.
original_tax_totalBigNumberValue
The original tax total of the order.
The total of the order.
The subtotal of the order. (Excluding taxes)
The tax total of the order.
discount_subtotalBigNumberValue
The discount subtotal of the order.
discount_totalBigNumberValue
The discount total of the order.
discount_tax_totalBigNumberValue
The discount tax total of the order.
gift_card_totalBigNumberValue
The gift card total of the order.
gift_card_tax_totalBigNumberValue
The gift card tax total of the order.
shipping_totalBigNumberValue
The shipping total of the order.
shipping_subtotalBigNumberValue
The shipping subtotal of the order.
shipping_tax_totalBigNumberValue
The shipping tax total of the order.
original_shipping_totalBigNumberValue
The original shipping total of the order.
original_shipping_subtotalBigNumberValue
The original shipping subtotal of the order.
original_shipping_tax_totalBigNumberValue
The original shipping tax total of the order.
raw_original_item_totalBigNumberRawValue
The raw original item total of the order.
raw_original_item_subtotalBigNumberRawValue
The raw original item subtotal of the order.
raw_original_item_tax_totalBigNumberRawValue
The raw original item tax total of the order.
raw_item_totalBigNumberRawValue
The raw item total of the order.
raw_item_subtotalBigNumberRawValue
The raw item subtotal of the order.
raw_item_tax_totalBigNumberRawValue
The raw item tax total of the order.
raw_original_totalBigNumberRawValue
The raw original total of the order.
raw_original_subtotalBigNumberRawValue
The raw original subtotal of the order.
raw_original_tax_totalBigNumberRawValue
The raw original tax total of the order.
The raw total of the order.
raw_subtotalBigNumberRawValue
The raw subtotal of the order. (Excluding taxes)
raw_tax_totalBigNumberRawValue
The raw tax total of the order.
raw_discount_totalBigNumberRawValue
The raw discount total of the order.
raw_discount_tax_totalBigNumberRawValue
The raw discount tax total of the order.
raw_gift_card_totalBigNumberRawValue
The raw gift card total of the order.
raw_gift_card_tax_totalBigNumberRawValue
The raw gift card tax total of the order.
raw_shipping_totalBigNumberRawValue
The raw shipping total of the order.
raw_shipping_subtotalBigNumberRawValue
The raw shipping subtotal of the order.
raw_shipping_tax_totalBigNumberRawValue
The raw shipping tax total of the order.
raw_original_shipping_totalBigNumberRawValue
The raw original shipping total of the order.
raw_original_shipping_subtotalBigNumberRawValue
The raw original shipping subtotal of the order.
raw_original_shipping_tax_totalBigNumberRawValue
The raw original shipping tax total of the order.
order_changeOrderChangeDTO
The details of the changes made on the order.
itemsOrderLineItemDTO & object[]
The items of the order, along with changes on the items.
shipping_methodsOrderShippingMethodDTO & object[]
The shipping methods of the order, along with changes on the shipping methods.
return_requested_totalnumber
The total amount for the requested return.
region_idstringOptional
The ID of the region the order belongs to.
customer_idstringOptional
The ID of the customer on the order.
sales_channel_idstringOptional
The ID of the sales channel the order belongs to.
emailstringOptional
The email of the order.
shipping_addressOrderAddressDTOOptional
The associated shipping address.
billing_addressOrderAddressDTOOptional
The associated billing address.
transactionsOrderTransactionDTO[]Optional
The tramsactions associated with the order
credit_linesOrderCreditLineDTO[]Optional
The credit lines for an order
summaryOrderSummaryDTOOptional
The summary of the order totals.
is_draft_orderbooleanOptional
Whether the order is a draft order.
metadatanull | Record<string, unknown>Optional
Holds custom data in key-value pairs.
canceled_atstring | DateOptional
When the order was canceled.

Hooks#

Hooks 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.

setPricingContext#

This hook is executed before the shipping method is updated. 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:

Code
1{2  "attribute": "location_id",3  "operator": "eq",4  "value": "sloc_123",5}

You can consume the setPricingContext hook to add the location_id context to the prices calculation:

Code
1import { updateExchangeShippingMethodWorkflow } from "@medusajs/medusa/core-flows";2import { StepResponse } from "@medusajs/workflows-sdk";3
4updateExchangeShippingMethodWorkflow.hooks.setPricingContext((5  { order_exchange, order_change, 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.

Note: Learn more about prices calculation context in the Prices Calculation documentation.

Example

Code
1import { updateExchangeShippingMethodWorkflow } from "@medusajs/medusa/core-flows"2
3updateExchangeShippingMethodWorkflow.hooks.setPricingContext(4  (async ({ order_exchange, order_change,5    additional_data }, { container }) => {6    //TODO7  })8)

Input

Handlers consuming this hook accept the following input.

inputinput
The input data for the hook.
order_exchangeOrderExchangeDTO
The exchange details.
order_changeOrderChangeDTO
The order change details.
additional_dataRecord<string, unknown> | undefined
Additional data that can be passed through the additional_data property in HTTP requests. Learn more in this documentation.
Was this page helpful?
Ask Anything
FAQ
What is Medusa?
How can I create a module?
How can I create a data model?
How do I create a workflow?
How can I extend a data model in the Product Module?
Recipes
How do I build a marketplace with Medusa?
How do I build digital products with Medusa?
How do I build subscription-based purchases with Medusa?
What other recipes are available in the Medusa documentation?
Chat is cleared on refresh
Line break