UNPKG

@medusajs/core-flows

Version:

Set of workflow definitions for Medusa

54 lines 2.23 kB
import { PromotionActions } from "@medusajs/framework/utils"; import { WorkflowData } from "@medusajs/framework/workflows-sdk"; /** * The details of the promotion updates on a cart. */ export type UpdateCartPromotionsWorkflowInput = { /** * The cart's ID. */ cart_id?: string; /** * The Cart reference. */ cart?: any; /** * The promotion codes to add to the cart, remove from the cart, * or replace all existing promotions in the cart. */ promo_codes?: string[]; /** * The action to perform with the specified promotion codes. */ action?: PromotionActions.ADD | PromotionActions.REMOVE | PromotionActions.REPLACE; }; export declare const updateCartPromotionsWorkflowId = "update-cart-promotions"; /** * This workflow updates a cart's promotions, applying or removing promotion codes from the cart. It also computes the adjustments * that need to be applied to the cart's line items and shipping methods based on the promotions applied. This workflow is used by * [Add Promotions Store API Route](https://docs.medusajs.com/api/store#carts_postcartsidpromotions). * * You can use this workflow within your own customizations or custom workflows, allowing you to update a cart's promotions within your custom flows. * * @example * const { result } = await updateCartPromotionsWorkflow(container) * .run({ * input: { * cart_id: "cart_123", * promo_codes: ["10OFF"], * // imported from @medusajs/framework/utils * action: PromotionActions.ADD, * } * }) * * @summary * * Update a cart's applied promotions to add, replace, or remove them. * * @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. */ export declare const updateCartPromotionsWorkflow: import("@medusajs/framework/workflows-sdk").ReturnWorkflow<UpdateCartPromotionsWorkflowInput, undefined, [import("@medusajs/framework/workflows-sdk").Hook<"validate", { input: WorkflowData<UpdateCartPromotionsWorkflowInput>; cart: any; }, unknown>]>; //# sourceMappingURL=update-cart-promotions.d.ts.map