diff --git a/www/apps/book/app/learn/fundamentals/workflows/workflow-hooks/page.mdx b/www/apps/book/app/learn/fundamentals/workflows/workflow-hooks/page.mdx index 9b894c92d8..b804d2cf50 100644 --- a/www/apps/book/app/learn/fundamentals/workflows/workflow-hooks/page.mdx +++ b/www/apps/book/app/learn/fundamentals/workflows/workflow-hooks/page.mdx @@ -4,11 +4,11 @@ export const metadata = { # {metadata.title} -In this chapter, you'll learn what a workflow hook is and how to consume them. +In this chapter, you'll learn what workflow hooks are and how to use them. ## What is a Workflow Hook? -A workflow hook is a point in a workflow where you can inject custom functionality as a step function, called a hook handler. +A workflow hook is a specific point in a workflow where you can inject custom functionality. This custom functionality is called a hook handler. Medusa exposes hooks in many of its workflows that are used in its API routes. You can consume those hooks to add your custom logic. @@ -28,13 +28,13 @@ You want to perform a custom action during a workflow's execution, such as when ## How to Consume a Hook? -A workflow has a special `hooks` property which is an object that holds its hooks. +A workflow has a special `hooks` property. This property is an object that contains all available hooks. So, in a TypeScript or JavaScript file created under the `src/workflows/hooks` directory: -- Import the workflow. -- Access its hook using the `hooks` property. -- Pass the hook a step function as a parameter to consume it. +1. Import the workflow. +2. Access the hook using the `hooks` property. +3. Pass a step function as a parameter to the hook. For example, to consume the `productsCreated` hook of Medusa's `createProductsWorkflow`, create the file `src/workflows/hooks/product-created.ts` with the following content: @@ -52,15 +52,15 @@ createProductsWorkflow.hooks.productsCreated( ) ``` -The `productsCreated` hook is available on the workflow's `hooks` property by its name. +The `productsCreated` hook is available in the workflow's `hooks` property. -You invoke the hook, passing a step function (the hook handler) as a parameter. +You call the hook and pass a step function (the hook handler) as a parameter. -Now, when a product is created using the [Create Product API route](!api!/admin#products_postproducts), your hook handler is executed after the product is created. +Now, when a product is created using the [Create Product API route](!api!/admin#products_postproducts), your hook handler runs after the product is created. -A hook can have only one handler. +A hook can have only one handler. So, you can't consume the same hook multiple times. @@ -74,7 +74,9 @@ Refer to the [createProductsWorkflow reference](!resources!/references/medusa-wo Since a hook handler is essentially a step function, it receives the hook's input as a first parameter, and an object holding a `container` property as a second parameter. -Each hook has different input. For example, the `productsCreated` hook receives an object having a `products` property holding the created product. +Each hook has different input. For example, the `productsCreated` hook receives an object with a `products` property that contains the created product. + +You can find the input for each workflow's hooks in the [Core Workflows Reference](!resources!/medusa-workflows-reference). ### Hook Handler Compensation @@ -97,15 +99,15 @@ createProductsWorkflow.hooks.productsCreated( ) ``` -The compensation function is executed if an error occurs in the workflow to undo the actions performed by the hook handler. +The compensation function runs if an error occurs in the workflow. It undoes the actions performed by the hook handler. -The compensation function receives as an input the second parameter passed to the `StepResponse` returned by the step function. +The compensation function receives the second parameter passed to the `StepResponse` returned by the step function as input. -It also accepts as a second parameter an object holding a `container` property to resolve resources from the Medusa container. +It also accepts an object with a `container` property as a second parameter. This allows you to resolve resources from the Medusa container. ### Additional Data Property -Medusa's workflows pass in the hook's input an `additional_data` property: +Medusa's workflows include an `additional_data` property in the hook's input: ```ts title="src/workflows/hooks/product-created.ts" highlights={[["4", "additional_data"]]} import { createProductsWorkflow } from "@medusajs/medusa/core-flows" @@ -117,17 +119,13 @@ createProductsWorkflow.hooks.productsCreated( ) ``` -This property is an object that holds additional data passed to the workflow through the request sent to the API route using the workflow. +This property is an object that contains additional data passed to the workflow through the request sent to the API route. - - -Learn how to pass `additional_data` in requests to API routes in [this chapter](../../api-routes/additional-data/page.mdx). - - +Learn how to pass `additional_data` in requests to API routes in the [Additional Data](../../api-routes/additional-data/page.mdx) chapter. ### Pass Additional Data to Workflow -You can also pass that additional data when executing the workflow. Pass it as a parameter to the `.run` method of the workflow: +You can also pass additional data when running the workflow. Pass it as a parameter to the workflow's `.run` method: ```ts title="src/workflows/hooks/product-created.ts" highlights={[["10", "additional_data"]]} import type { MedusaRequest, MedusaResponse } from "@medusajs/framework/http" @@ -147,4 +145,4 @@ export async function POST(req: MedusaRequest, res: MedusaResponse) { } ``` -Your hook handler then receives that passed data in the `additional_data` object. +Your hook handler then receives the passed data in the `additional_data` object. diff --git a/www/apps/book/app/learn/storefront-development/page.mdx b/www/apps/book/app/learn/storefront-development/page.mdx index e5c5e22c82..64dbc5bcb3 100644 --- a/www/apps/book/app/learn/storefront-development/page.mdx +++ b/www/apps/book/app/learn/storefront-development/page.mdx @@ -6,9 +6,15 @@ export const metadata = { # {metadata.title} -The Medusa application is made up of a Node.js server and an admin dashboard. Storefronts are installed, built, and hosted separately from the Medusa application, giving you the flexibility to choose the frontend tech stack that you and your team are proficient in, and implement unique design systems and user experience. +In this chapter, you'll learn about storefronts and how to build one. -You can build your storefront from scratch with your preferred tech stack, or start with our Next.js Starter storefront. The Next.js Starter storefront provides rich commerce features and a sleek design. Developers and businesses can use it as-is or build on top of it to tailor it for the business's unique use case, design, and customer experience. +## Storefronts in Medusa + +The Medusa application includes a Node.js server and an admin dashboard. Storefronts are separate applications that you install, build, and host independently from Medusa. This gives you the flexibility to choose your preferred frontend tech stack and implement unique designs and user experiences. + +In your storefront, you can retrieve data and perform commerce operations by sending requests to the Medusa application's [Store API routes](!api!/store) and your custom API routes. + +You can build your storefront from scratch with your preferred tech stack, or start with our Next.js Starter storefront. The Next.js Starter storefront provides rich commerce features and a modern design. You can use it as-is or customize it to match your business needs, design requirements, and customer experience goals. @@ -14,51 +14,53 @@ Refer to this [Medusa Admin User Guide](!user-guide!/orders/claims) to learn how ## What is a Claim? -When a customer receives a defective or incorrect item, the merchant can create a claim to refund or replace the item. +When a customer receives a defective or incorrect item, the merchant can create a claim to refund or replace that item. -The [OrderClaim data model](/references/order/models/OrderClaim) represents a claim. +A claim is represented by the [OrderClaim data model](/references/order/models/OrderClaim). --- ## Claim Type -The `Claim` data model has a `type` property whose value indicates the type of the claim: +The `Claim` data model has a `type` property that indicates the type of claim: -- `refund`: the items are returned, and the customer is refunded. -- `replace`: the items are returned, and the customer receives new items. +- `refund`: The items are returned and the customer receives a refund. +- `replace`: The items are returned and the customer receives new items. --- ## Old and Replacement Items -When the claim is created, a return, represented by the [Return data model](/references/order/models/Return), is also created to handle receiving the old items from the customer. +When you create a claim, a return is also created to handle receiving the old items from the customer. The return is represented by the [Return data model](/references/order/models/Return). -Learn more about returns in [this guide](../return/page.mdx). +Refer to the [Returns](../return/page.mdx) guide to learn more about returns. -If the claim’s type is `replace`, replacement items are represented by the [ClaimItem data model](/references/order/models/OrderClaimItem). +If the claim's type is `replace`, the replacement items are represented by the [ClaimItem data model](/references/order/models/OrderClaimItem). --- ## Claim Shipping Methods -A claim uses shipping methods to send the replacement items to the customer. These methods are represented by the [OrderShippingMethod data model](/references/order/models/OrderShippingMethod). +A claim uses shipping methods to send replacement items to the customer. These methods are represented by the [OrderShippingMethod data model](/references/order/models/OrderShippingMethod). -The shipping methods for the returned items are associated with the claim's return, as explained in [this guide](../return/page.mdx#return-shipping-methods). +The shipping methods for returned items are linked to the claim's return, as explained in the [Returns](../return/page.mdx#return-shipping-methods) guide. --- ## Claim Refund -If the claim’s type is `refund`, the amount to be refunded is stored in the `refund_amount` property. +If the claim's type is `refund`, the refund amount is stored in the `refund_amount` property. The [Transaction data model](/references/order/models/OrderTransaction) represents the refunds made for the claim. --- -## How Claims Impact an Order’s Version +## How Claims Impact an Order's Version -When a claim is confirmed, the order’s version is incremented. +When you confirm a claim, the order's version increases. + +Learn more about order versions in the [Order Versioning](../order-versioning/page.mdx) guide. \ No newline at end of file diff --git a/www/apps/resources/generated/edit-dates.mjs b/www/apps/resources/generated/edit-dates.mjs index 9ebd852c9d..e411c39844 100644 --- a/www/apps/resources/generated/edit-dates.mjs +++ b/www/apps/resources/generated/edit-dates.mjs @@ -28,12 +28,12 @@ export const generatedEditDates = { "app/commerce-modules/fulfillment/page.mdx": "2025-05-20T07:51:40.707Z", "app/commerce-modules/inventory/_events/_events-table/page.mdx": "2024-07-03T19:27:13+03:00", "app/commerce-modules/inventory/_events/page.mdx": "2024-07-03T19:27:13+03:00", - "app/commerce-modules/inventory/concepts/page.mdx": "2025-02-13T12:37:28.918Z", + "app/commerce-modules/inventory/concepts/page.mdx": "2025-09-16T16:03:29.634Z", "app/commerce-modules/inventory/inventory-in-flows/page.mdx": "2025-01-08T12:21:12.157Z", "app/commerce-modules/inventory/page.mdx": "2025-04-17T08:48:24.991Z", "app/commerce-modules/order/_events/_events-table/page.mdx": "2024-07-03T19:27:13+03:00", "app/commerce-modules/order/_events/page.mdx": "2024-07-03T19:27:13+03:00", - "app/commerce-modules/order/claim/page.mdx": "2025-02-26T11:23:55.003Z", + "app/commerce-modules/order/claim/page.mdx": "2025-09-16T16:07:25.033Z", "app/commerce-modules/order/concepts/page.mdx": "2025-08-21T15:05:58.124Z", "app/commerce-modules/order/exchange/page.mdx": "2025-02-26T11:23:29.845Z", "app/commerce-modules/order/order-versioning/page.mdx": "2025-08-21T15:31:58.563Z",