Skip to content

Commit d81b3d0

Browse files
committed
docs: added gift message guide
1 parent 10dff3e commit d81b3d0

14 files changed

Lines changed: 2025 additions & 28 deletions

File tree

www/apps/book/public/llms-full.txt

Lines changed: 1266 additions & 6 deletions
Large diffs are not rendered by default.

www/apps/resources/app/how-to-tutorials/tutorials/first-purchase-discounts/page.mdx

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export const metadata = {
2727

2828
In this tutorial, you'll learn how to implement first-purchase discounts in Medusa.
2929

30-
When you install a Medusa application, you get a fully-fledged commerce platform with a Framework for customization. The Medusa application's commerce features are built around [Commerce Modules](../../../commerce-modules/page.mdx), which are available out-of-the-box. These features include promotion and discount management features.
30+
When you install a Medusa application, you get a fully-fledged commerce platform with a Framework for customization. The Medusa application's commerce features are built around [Commerce Modules](../../../commerce-modules/page.mdx), which are available out-of-the-box. These features include promotion and cart management features.
3131

3232
The first-purchase discount feature encourages customers to sign up and make their first purchase by offering them a discount. In this tutorial, you'll learn how to implement this feature in Medusa.
3333

@@ -228,8 +228,8 @@ export const applyFirstPurchasePromoWorkflow = createWorkflow(
228228
entity: "cart",
229229
fields: ["promotions.*", "customer.*", "customer.orders.*"],
230230
filters: {
231-
id: input.cart_id
232-
}
231+
id: input.cart_id,
232+
},
233233
})
234234

235235
// @ts-ignore
@@ -238,13 +238,13 @@ export const applyFirstPurchasePromoWorkflow = createWorkflow(
238238
fields: ["code"],
239239
filters: {
240240
// @ts-ignore
241-
code: FIRST_PURCHASE_PROMOTION_CODE
242-
}
241+
code: FIRST_PURCHASE_PROMOTION_CODE,
242+
},
243243
}).config({ name: "retrieve-promotions" })
244244

245245
when({
246246
carts,
247-
promotions
247+
promotions,
248248
}, (data) => {
249249
return data.promotions.length > 0 &&
250250
!data.carts[0].promotions?.some((promo) => promo?.id === data.promotions[0].id) &&
@@ -255,7 +255,7 @@ export const applyFirstPurchasePromoWorkflow = createWorkflow(
255255
updateCartPromotionsStep({
256256
id: carts[0].id,
257257
promo_codes: [promotions[0].code!],
258-
action: PromotionActions.ADD
258+
action: PromotionActions.ADD,
259259
})
260260
})
261261

@@ -265,8 +265,8 @@ export const applyFirstPurchasePromoWorkflow = createWorkflow(
265265
entity: "cart",
266266
fields: ["*", "promotions.*"],
267267
filters: {
268-
id: input.cart_id
269-
}
268+
id: input.cart_id,
269+
},
270270
}).config({ name: "retrieve-updated-cart" })
271271

272272
return new WorkflowResponse(updatedCarts[0])
@@ -323,8 +323,8 @@ export default async function cartCreatedHandler({
323323
await applyFirstPurchasePromoWorkflow(container)
324324
.run({
325325
input: {
326-
cart_id: data.id
327-
}
326+
cart_id: data.id,
327+
},
328328
})
329329
}
330330

@@ -433,8 +433,8 @@ updateCartPromotionsWorkflow.hooks.validate(
433433
entity: "customer",
434434
fields: ["orders.*", "has_account"],
435435
filters: {
436-
id: cart.customer_id
437-
}
436+
id: cart.customer_id,
437+
},
438438
})
439439

440440
if (!customer.has_account || (customer?.orders?.length || 0) > 0) {
@@ -478,7 +478,7 @@ In the same `src/workflows/hooks/validate-promotion.ts` file, add the following
478478

479479
```ts title="src/workflows/hooks/validate-promotion.ts"
480480
import {
481-
completeCartWorkflow
481+
completeCartWorkflow,
482482
} from "@medusajs/medusa/core-flows"
483483
```
484484

@@ -515,8 +515,8 @@ completeCartWorkflow.hooks.validate(
515515
entity: "customer",
516516
fields: ["orders.*", "has_account"],
517517
filters: {
518-
id: cart.customer_id
519-
}
518+
id: cart.customer_id,
519+
},
520520
})
521521

522522
if (!customer.has_account || (customer?.orders?.length || 0) > 0) {

0 commit comments

Comments
 (0)