Skip to content

Commit f614d86

Browse files
authored
docs: added gift message guide (medusajs#12833)
1 parent 98de6b6 commit f614d86

File tree

11 files changed

+741
-18
lines changed

11 files changed

+741
-18
lines changed

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

Lines changed: 14 additions & 14 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

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

234234
const { data: promotions } = useQueryGraphStep({
@@ -241,7 +241,7 @@ export const applyFirstPurchasePromoWorkflow = createWorkflow(
241241

242242
when({
243243
carts,
244-
promotions
244+
promotions,
245245
}, (data) => {
246246
return data.promotions.length > 0 &&
247247
!data.carts[0].promotions?.some((promo) => promo?.id === data.promotions[0].id) &&
@@ -252,7 +252,7 @@ export const applyFirstPurchasePromoWorkflow = createWorkflow(
252252
updateCartPromotionsStep({
253253
id: carts[0].id,
254254
promo_codes: [promotions[0].code!],
255-
action: PromotionActions.ADD
255+
action: PromotionActions.ADD,
256256
})
257257
})
258258

@@ -261,8 +261,8 @@ export const applyFirstPurchasePromoWorkflow = createWorkflow(
261261
entity: "cart",
262262
fields: ["*", "promotions.*"],
263263
filters: {
264-
id: input.cart_id
265-
}
264+
id: input.cart_id,
265+
},
266266
}).config({ name: "retrieve-updated-cart" })
267267

268268
return new WorkflowResponse(updatedCarts[0])
@@ -319,8 +319,8 @@ export default async function cartCreatedHandler({
319319
await applyFirstPurchasePromoWorkflow(container)
320320
.run({
321321
input: {
322-
cart_id: data.id
323-
}
322+
cart_id: data.id,
323+
},
324324
})
325325
}
326326

@@ -429,8 +429,8 @@ updateCartPromotionsWorkflow.hooks.validate(
429429
entity: "customer",
430430
fields: ["orders.*", "has_account"],
431431
filters: {
432-
id: cart.customer_id
433-
}
432+
id: cart.customer_id,
433+
},
434434
})
435435

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

475475
```ts title="src/workflows/hooks/validate-promotion.ts"
476476
import {
477-
completeCartWorkflow
477+
completeCartWorkflow,
478478
} from "@medusajs/medusa/core-flows"
479479
```
480480

@@ -511,8 +511,8 @@ completeCartWorkflow.hooks.validate(
511511
entity: "customer",
512512
fields: ["orders.*", "has_account"],
513513
filters: {
514-
id: cart.customer_id
515-
}
514+
id: cart.customer_id,
515+
},
516516
})
517517

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

0 commit comments

Comments
 (0)