import { WorkflowData } from "@medusajs/framework/workflows-sdk"; import { AdditionalData, ListShippingOptionsForCartWorkflowInput } from "@medusajs/framework/types"; export declare const listShippingOptionsForCartWorkflowId = "list-shipping-options-for-cart"; /** * This workflow lists the shipping options of a cart. It's executed by the * [List Shipping Options Store API Route](https://docs.medusajs.com/api/store#shipping-options_getshippingoptions). * * :::note * * This workflow doesn't retrieve the calculated prices of the shipping options. If you need to retrieve the prices of the shipping options, * use the {@link listShippingOptionsForCartWithPricingWorkflow} workflow. * * ::: * * You can use this workflow within your own customizations or custom workflows, allowing you to wrap custom logic around to retrieve the shipping options of a cart * in your custom flows. * * @example * const { result } = await listShippingOptionsForCartWorkflow(container) * .run({ * input: { * cart_id: "cart_123", * option_ids: ["so_123"] * } * }) * * @summary * * List a cart's shipping options. * * @property hooks.setPricingContext - This hook is executed before the shipping options are retrieved. You can consume this hook to return any custom context useful for the prices retrieval of shipping options. * * For example, assuming you have the following custom pricing rule: * * ```json * { * "attribute": "location_id", * "operator": "eq", * "value": "sloc_123", * } * ``` * * You can consume the `setPricingContext` hook to add the `location_id` context to the prices calculation: * * ```ts * import { listShippingOptionsForCartWorkflow } from "@medusajs/medusa/core-flows"; * import { StepResponse } from "@medusajs/workflows-sdk"; * * listShippingOptionsForCartWorkflow.hooks.setPricingContext(( * { cart, fulfillmentSetIds, additional_data }, { container } * ) => { * return new StepResponse({ * location_id: "sloc_123", // Special price for in-store purchases * }); * }); * ``` * * The shipping options' prices will now be retrieved using the context you return. * * :::note * * Learn more about prices calculation context in the [Prices Calculation](https://docs.medusajs.com/resources/commerce-modules/pricing/price-calculation) documentation. * * ::: * * @property hooks.setShippingOptionsContext - This hook is executed after the cart is retrieved and before the shipping options are queried. You can consume this hook to return any custom context useful for the shipping options retrieval. * * For example, you can consume the hook to add the customer Id to the context: * * ```ts * import { listShippingOptionsForCartWithPricingWorkflow } from "@medusajs/medusa/core-flows" * import { StepResponse } from "@medusajs/workflows-sdk" * * listShippingOptionsForCartWithPricingWorkflow.hooks.setShippingOptionsContext( * async ({ cart }, { container }) => { * * if (cart.customer_id) { * return new StepResponse({ * customer_id: cart.customer_id, * }) * } * * const query = container.resolve("query") * * const { data: carts } = await query.graph({ * entity: "cart", * filters: { * id: cart.id, * }, * fields: ["customer_id"], * }) * * return new StepResponse({ * customer_id: carts[0].customer_id, * }) * } * ) * ``` * * The `customer_id` property will be added to the context along with other properties such as `is_return` and `enabled_in_store`. * * :::note * * You should also consume the `setShippingOptionsContext` hook in the {@link listShippingOptionsForCartWithPricingWorkflow} workflow to ensure that the context is consistent when listing shipping options across workflows. * * ::: */ export declare const listShippingOptionsForCartWorkflow: import("@medusajs/framework/workflows-sdk").ReturnWorkflow) & string[]; additional_data: ((Record | WorkflowData | undefined>) & Record) | undefined; }, Record | undefined>, import("@medusajs/framework/workflows-sdk").Hook<"setShippingOptionsContext", { cart: any; fulfillmentSetIds: (string[] | WorkflowData) & string[]; additional_data: ((Record | WorkflowData | undefined>) & Record) | undefined; }, Record | undefined>]>; //# sourceMappingURL=list-shipping-options-for-cart.d.ts.map