chore: add tsdocs for latest changes (#13539)

This commit is contained in:
Shahed Nasser
2025-09-18 18:04:24 +03:00
committed by GitHub
parent 57897c232e
commit aa7ea4d9a6
8 changed files with 133 additions and 42 deletions
@@ -75,6 +75,48 @@ export const listShippingOptionsForCartWithPricingWorkflowId =
* @summary
*
* List a cart's shipping options with prices.
*
* @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 listShippingOptionsForCartWorkflow} workflow to ensure that the context is consistent when listing shipping options across workflows.
*
* :::
*/
export const listShippingOptionsForCartWithPricingWorkflow = createWorkflow(
listShippingOptionsForCartWithPricingWorkflowId,
@@ -84,6 +84,48 @@ export const listShippingOptionsForCartWorkflowId =
* 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 const listShippingOptionsForCartWorkflow = createWorkflow(
listShippingOptionsForCartWorkflowId,