- Get Started
- Product
- Resources
- Tools & SDKs
- Framework
- Reference
- Get Started
- Product
- Resources
- Tools & SDKs
- Framework
- Reference
updateCartWorkflow - Medusa Core Workflows Reference
This documentation provides a reference to the updateCartWorkflow
. It belongs to the @medusajs/medusa/core-flows
package.
This workflow updates a cart and returns it. You can update the cart's region, address, and more. This workflow is executed by the Update Cart Store API Route.
This workflow has a hook that allows you to perform custom actions on the updated cart. For example, you can pass custom data under the additional_data
property of the Update Cart API route,
then update any associated details related to the cart in the workflow's hook.
You can also use this workflow within your customizations or your own custom workflows, allowing you to wrap custom logic around updating a cart.
Source CodeExamples#
Steps#
Workflow Hook
Step conditioned by when
Input#
UpdateCartWorkflowInput
UpdateCartWorkflowInputThe data to update the cart, along with custom data that's passed to the workflow's hooks.
UpdateCartWorkflowInput
UpdateCartWorkflowInputid
stringThe ID of the cart to update.
id
stringpromo_codes
string[]OptionalAn array of promotional codes applied on the cart.
promo_codes
string[]Optionalregion_id
stringOptionalThe ID of the cart's region.
region_id
stringOptionalcustomer_id
null | stringOptionalThe ID of the cart's customer.
customer_id
null | stringOptionalsales_channel_id
null | stringOptionalThe ID of the cart's sales channel.
sales_channel_id
null | stringOptionalemail
null | stringOptionalThe email address of the cart's customer.
email
null | stringOptionalcurrency_code
stringOptionalThe currency code for the cart.
currency_code
stringOptionalmetadata
null | Record<string, unknown>OptionalCustom key-value pairs of data related to the cart.
metadata
null | Record<string, unknown>OptionalThe cart's shipping address. You can either update the cart's existing shipping address, or create a new one.
The cart's billing address. You can either update the cart's existing billing address, or create a new one.
additional_data
Record<string, unknown>OptionalAdditional data that can be passed through the additional_data
property in HTTP requests.
Learn more in this documentation.
additional_data
Record<string, unknown>Optionaladditional_data
property in HTTP requests.
Learn more in this documentation.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.
validate#
This hook is executed before all operations. You can consume this hook to perform any custom validation. If validation fails, you can throw an error to stop the workflow execution.
Example
Input
Handlers consuming this hook accept the following input.
input
objectThe input data for the hook.
input
objectinput
object
input
objectcart
any
cart
anycartUpdated#
This hook is executed after a cart is update. You can consume this hook to perform custom actions on the updated cart.
Example
Input
Handlers consuming this hook accept the following input.
input
objectThe input data for the hook.
input
objectcart
any
cart
anyadditional_data
Record<string, unknown> | undefinedAdditional data that can be passed through the additional\_data
property in HTTP requests.
Learn more in this documentation.
additional_data
Record<string, unknown> | undefinedadditional\_data
property in HTTP requests.
Learn more in this documentation.