UNPKG

@medusajs/core-flows

Version:

Set of workflow definitions for Medusa

68 lines 3.21 kB
import { AdditionalData, UpdateCartWorkflowInputDTO } from "@medusajs/framework/types"; import { WorkflowData } from "@medusajs/framework/workflows-sdk"; /** * The data to update the cart, along with custom data that's passed to the workflow's hooks. */ export type UpdateCartWorkflowInput = UpdateCartWorkflowInputDTO & AdditionalData; export declare const updateCartWorkflowId = "update-cart"; /** * 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](https://docs.medusajs.com/api/store#carts_postcartsid). * * :::note * * This workflow doesn't allow updating a cart's line items. Instead, use {@link addToCartWorkflow} and {@link updateLineItemInCartWorkflow}. * * ::: * * 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. * * @example * const { result } = await updateCartWorkflow(container) * .run({ * input: { * id: "cart_123", * region_id: "region_123", * shipping_address: { * first_name: "John", * last_name: "Doe", * address_1: "1234 Main St", * city: "San Francisco", * country_code: "US", * postal_code: "94111", * phone: "1234567890", * }, * additional_data: { * external_id: "123" * } * } * }) * * @summary * * Update a cart's details, such as region, address, and more. * * @property hooks.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. * @property hooks.cartUpdated - This hook is executed after a cart is update. You can consume this hook to perform custom actions on the updated cart. */ export declare const updateCartWorkflow: import("@medusajs/framework/workflows-sdk").ReturnWorkflow<UpdateCartWorkflowInput, undefined, [import("@medusajs/framework/workflows-sdk").Hook<"validate", { input: WorkflowData<{ currency_code: any; region_id: any; id: string; customer_id?: string | null; sales_channel_id?: string | null; email?: string | null; metadata?: Record<string, unknown> | null; shipping_address?: import("@medusajs/framework/types").CreateAddressDTO | import("@medusajs/framework/types").UpdateAddressDTO | null; billing_address?: import("@medusajs/framework/types").CreateAddressDTO | import("@medusajs/framework/types").UpdateAddressDTO | null; }>; cart: any; }, unknown>, import("@medusajs/framework/workflows-sdk").Hook<"cartUpdated", { cart: any; additional_data: ((Record<string, unknown> | WorkflowData<Record<string, unknown> | undefined>) & Record<string, unknown>) | undefined; }, unknown>]>; //# sourceMappingURL=update-cart.d.ts.map