1 ---
2 sidebar_label: "Abandoned Cart Notification"
3 tags:
4 - name: cart
5 label: "Send Abandoned Cart Notification"
6 - server
7 - tutorial
8 - notification
9 products:
10 - cart
11 ---
12
13 import { Github, PlaySolid } from "@medusajs/icons"
14 import { Prerequisites, WorkflowDiagram, Card } from "docs-ui"
15
16 export const ogImage = "https://res.cloudinary.com/dza7lstvk/image/upload/v1743097105/Medusa%20Resources/abandoned-cart_eze9ng.jpg"
17
18 export const metadata = {
19 title: `Send Abandoned Cart Notifications in Medusa`,
20 openGraph: {
21 images: [
22 {
23 url: ogImage,
24 width: 1600,
25 height: 836,
26 type: "image/jpeg"
27 }
28 ],
29 },
30 twitter: {
31 images: [
32 {
33 url: ogImage,
34 width: 1600,
35 height: 836,
36 type: "image/jpeg"
37 }
38 ]
39 }
40 }
41
42 # {metadata.title}
43
44 In this tutorial, you will learn how to send notifications to customers who have abandoned their carts.
45
46 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 cart-management capabilities.
47
48 Medusa's [Notification Module](../../../infrastructure-modules/notification/page.mdx) allows you to send notifications to users or customers, such as password reset emails, order confirmation SMS, or other types of notifications.
49
50 In this tutorial, you will use the Notification Module to send an email to customers who have abandoned their carts. The email will contain a link to recover the customer's cart, encouraging them to complete their purchase. You will use SendGrid to send the emails, but you can also use other email providers.
51
52 ## Summary
53
54 By following this tutorial, you will:
55
56 - Install and set up Medusa.
57 - Create the logic to send an email to customers who have abandoned their carts.
58 - Run the above logic once a day.
59 - Add a route to the storefront to recover the cart.
60
61 ![Diagram illustrating the flow of the abandoned-cart functionalities](https://res.cloudinary.com/dza7lstvk/image/upload/v1742460588/Medusa%20Resources/abandoned-cart-summary_fcf2tn.jpg)
62
63 <Card
64 title="View on Github"
65 icon={Github}
66 href="https://github.com/medusajs/examples/tree/main/abandoned-cart"
67 text="Find the full code for this tutorial."
68 />
69
70 ---
71
72 ## Step 1: Install a Medusa Application
73
74 <Prerequisites items={[
75 {
76 text: "Node.js v20.19.0+ or v22.12.0+",
77 link: "https://nodejs.org/en/download"
78 },
79 {
80 text: "Git CLI tool",
81 link: "https://git-scm.com/downloads"
82 },
83 {
84 text: "PostgreSQL",
85 link: "https://www.postgresql.org/download/"
86 }
87 ]} />
88
89 Start by installing the Medusa application on your machine with the following command:
90
91 ```bash npx2yarnExec
92 npx create-medusa-app@latest
93 ```
94
95 You will first be asked for the project's name. Then, when asked whether you want to install the [Next.js Starter Storefront](../../../nextjs-starter/page.mdx), choose "Yes."
96
97 Afterwards, the installation process will start, which will install the Medusa application as a monorepository in a directory with your project's name. The backend is installed in the `apps/backend` directory, and the Next.js Starter Storefront is installed in the `apps/storefront` directory.
98
99 Once the installation finishes successfully, the Medusa Admin dashboard will open with a form to create a new user. Enter the user's credentials and submit the form. Afterwards, you can log in with the new user and explore the dashboard.
100
101 <Note title="Ran into Errors">
102
103 Check out the [troubleshooting guides](../../../troubleshooting/create-medusa-app-errors/page.mdx) for help.
104
105 </Note>
106
107 <Note>
108
109 In this guide, all file paths of backend customizations are relative to the `apps/backend` directory of your Medusa project.
110
111 </Note>
112
113 ---
114
115 ## Step 2: Set up SendGrid
116
117 <Prerequisites items={[
118 {
119 text: "SendGrid account",
120 link: "https://sendgrid.com"
121 },
122 {
123 text: "Verified Sender Identity",
124 link: "https://mc.sendgrid.com/senders"
125 },
126 {
127 text: "SendGrid API Key",
128 link: "https://app.sendgrid.com/settings/api_keys"
129 }
130 ]} />
131
132 Medusa's Notification Module provides the general functionality to send notifications, but the sending logic is implemented in a module provider. This allows you to integrate the email provider of your choice.
133
134 To send the cart-abandonment emails, you will use SendGrid. Medusa provides a [SendGrid Notification Module Provider](../../../infrastructure-modules/notification/sendgrid/page.mdx) that you can use to send emails.
135
136 Alternatively, you can use [other Notification Module Providers](../../../infrastructure-modules/notification/page.mdx#what-is-a-notification-module-provider) or [create a custom provider](/references/notification-provider-module).
137
138 To set up SendGrid, add the SendGrid Notification Module Provider to `medusa-config.ts`:
139
140 ```ts title="medusa-config.ts"
141 module.exports = defineConfig({
142 // ...
143 modules: [
144 {
145 resolve: "@medusajs/medusa/notification",
146 options: {
147 providers: [
148 {
149 resolve: "@medusajs/medusa/notification-sendgrid",
150 id: "sendgrid",
151 options: {
152 channels: ["email"],
153 api_key: process.env.SENDGRID_API_KEY,
154 from: process.env.SENDGRID_FROM,
155 },
156 },
157 ],
158 },
159 },
160 ],
161 })
162 ```
163
164 In the `modules` configuration, you pass the Notification Provider and add SendGrid as a provider. You also pass to the SendGrid Module Provider the following options:
165
166 - `channels`: The channels that the provider supports. In this case, it is only email.
167 - `api_key`: Your SendGrid API key.
168 - `from`: The email address that the emails will be sent from.
169
170 Then, set the SendGrid API key and "from" email as environment variables, such as in the `.env` file at the root of your project:
171
172 ```plain
173 SENDGRID_API_KEY=your-sendgrid-api-key
174 SENDGRID_FROM=test@gmail.com
175 ```
176
177 You can now use SendGrid to send emails in Medusa.
178
179 ---
180
181 ## Step 3: Send Abandoned Cart Notification Flow
182
183 You will now implement the sending logic for the abandoned cart notifications.
184
185 To build custom commerce features in Medusa, you create a [workflow](!docs!/learn/fundamentals/workflows). A workflow is a series of queries and actions, called steps, that complete a task. You construct a workflow like you construct a function, but it is a special function that allows you to track its executions' progress, define roll-back logic, and configure other advanced features. Then, you execute the workflow from other customizations, such as in a scheduled job.
186
187 In this step, you will create the workflow that sends the abandoned cart notifications. Later, you will learn how to execute it once a day.
188
189 The workflow will receive the list of abandoned carts as an input. The workflow has the following steps:
190
191 <WorkflowDiagram
192 workflow={{
193 name: "sendAbandonedCartsWorkflow",
194 steps: [
195 {
196 name: "sendAbandonedNotificationsStep",
197 type: "step",
198 description: "Send the abandoned cart notifications.",
199 depth: 1
200 },
201 {
202 name: "updateCartsStep",
203 type: "step",
204 description: "Update the cart to store the last notification date.",
205 depth: 1,
206 link: "/references/medusa-workflows/steps/updateCartsStep"
207 }
208 ]
209 }}
210 hideLegend
211 />
212
213 Medusa provides the second step in its `@medusajs/medusa/core-flows` package. So, you only need to implement the first one.
214
215 ### sendAbandonedNotificationsStep
216
217 The first step of the workflow sends a notification to the owners of the abandoned carts that are passed as an input.
218
219 To implement the step, create the file `src/workflows/steps/send-abandoned-notifications.ts` with the following content:
220
221 ```ts title="src/workflows/steps/send-abandoned-notifications.ts"
222 import {
223 createStep,
224 StepResponse,
225 } from "@medusajs/framework/workflows-sdk"
226 import { Modules } from "@medusajs/framework/utils"
227 import { CartDTO, CustomerDTO } from "@medusajs/framework/types"
228
229 type SendAbandonedNotificationsStepInput = {
230 carts: (CartDTO & {
231 customer: CustomerDTO
232 })[]
233 }
234
235 export const sendAbandonedNotificationsStep = createStep(
236 "send-abandoned-notifications",
237 async (input: SendAbandonedNotificationsStepInput, { container }) => {
238 const notificationModuleService = container.resolve(
239 Modules.NOTIFICATION
240 )
241
242 const notificationData = input.carts.map((cart) => ({
243 to: cart.email!,
244 channel: "email",
245 template: process.env.ABANDONED_CART_TEMPLATE_ID || "",
246 data: {
247 customer: {
248 first_name: cart.customer?.first_name || cart.shipping_address?.first_name,
249 last_name: cart.customer?.last_name || cart.shipping_address?.last_name,
250 },
251 cart_id: cart.id,
252 items: cart.items?.map((item) => ({
253 product_title: item.title,
254 quantity: item.quantity,
255 unit_price: item.unit_price,
256 thumbnail: item.thumbnail,
257 })),
258 },
259 }))
260
261 const notifications = await notificationModuleService.createNotifications(
262 notificationData
263 )
264
265 return new StepResponse({
266 notifications,
267 })
268 }
269 )
270 ```
271
272 You create a step with `createStep` from the Workflows SDK. It accepts two parameters:
273
274 1. The step's unique name, which is `create-review`.
275 2. An async function that receives two parameters:
276 - The step's input, which is in this case an object with the review's properties.
277 - An object that has properties including the [Medusa container](!docs!/learn/fundamentals/medusa-container), which is a registry of Framework and commerce tools that you can access in the step.
278
279 In the step function, you first resolve the Notification Module's service, which has methods to manage notifications. Then, you prepare the data of each notification, and create the notifications with the `createNotifications` method.
280
281 Notice that each notification is an object with the following properties:
282
283 - `to`: The email address of the customer.
284 - `channel`: The channel that the notification will be sent through. The Notification Module uses the provider registered for the channel.
285 - `template`: The ID or name of the email template in the third-party provider. Make sure to set it as an environment variable once you have it.
286 - `data`: The data to pass to the template to render the email's dynamic content.
287
288 Based on the dynamic template you create in SendGrid or another provider, you can pass different data in the `data` object.
289
290 A step function must return a `StepResponse` instance. The `StepResponse` constructor accepts the step's output as a parameter, which is the created notifications.
291
292 ### Create Workflow
293
294 You can now create the workflow that uses the step you just created to send the abandoned cart notifications.
295
296 Create the file `src/workflows/send-abandoned-carts.ts` with the following content:
297
298 ```ts title="src/workflows/send-abandoned-carts.ts"
299 import {
300 createWorkflow,
301 WorkflowResponse,
302 transform,
303 } from "@medusajs/framework/workflows-sdk"
304 import {
305 sendAbandonedNotificationsStep,
306 } from "./steps/send-abandoned-notifications"
307 import { updateCartsStep } from "@medusajs/medusa/core-flows"
308 import { CartDTO } from "@medusajs/framework/types"
309 import { CustomerDTO } from "@medusajs/framework/types"
310
311 export type SendAbandonedCartsWorkflowInput = {
312 carts: (CartDTO & {
313 customer: CustomerDTO
314 })[]
315 }
316
317 export const sendAbandonedCartsWorkflow = createWorkflow(
318 "send-abandoned-carts",
319 function (input: SendAbandonedCartsWorkflowInput) {
320 sendAbandonedNotificationsStep(input)
321
322 const updateCartsData = transform(
323 input,
324 (data) => {
325 return data.carts.map((cart) => ({
326 id: cart.id,
327 metadata: {
328 ...cart.metadata,
329 abandoned_notification: new Date().toISOString(),
330 },
331 }))
332 }
333 )
334
335 const updatedCarts = updateCartsStep(updateCartsData)
336
337 return new WorkflowResponse(updatedCarts)
338 }
339 )
340 ```
341
342 You create a workflow using `createWorkflow` from the Workflows SDK. It accepts the workflow's unique name as a first parameter.
343
344 It accepts as a second parameter a constructor function, which is the workflow's implementation. The function can accept input, which in this case is an arra of carts.
345
346 In the workflow's constructor function, you:
347
348 - Use the `sendAbandonedNotificationsStep` to send the notifications to the carts' customers.
349 - Use the `updateCartsStep` from Medusa's core flows to update the carts' metadata with the last notification date.
350
351 Notice that you use the `transform` function to prepare the `updateCartsStep`'s input. Medusa does not support direct data manipulation in a workflow's constructor function. You can learn more about it in the [Data Manipulation in Workflows documentation](!docs!/learn/fundamentals/workflows/variable-manipulation).
352
353 Your workflow is now ready for use. You will learn how to execute it in the next section.
354
355 ### Setup Email Template
356
357 Before you can test the workflow, you need to set up an email template in SendGrid. The template should contain the dynamic content that you pass in the workflow's step.
358
359 To create an email template in SendGrid:
360
361 - Go to [Dynamic Templates](https://mc.sendgrid.com/dynamic-templates) in the SendGrid dashboard.
362 - Click on the "Create Dynamic Template" button.
363
364 ![Button is at the top right of the page](https://res.cloudinary.com/dza7lstvk/image/upload/v1742457153/Medusa%20Resources/Screenshot_2025-03-20_at_9.51.38_AM_g5nk80.png)
365
366 - In the side window that opens, enter a name for the template, then click on the Create button.
367 - The template will be added to the middle of the page. When you click on it, a new section will show with an "Add Version" button. Click on it.
368
369 ![The template is a collapsible in the middle of the page,with the "Add Version" button shown in the middle](https://res.cloudinary.com/dza7lstvk/image/upload/v1742458096/Medusa%20Resources/Screenshot_2025-03-20_at_10.07.54_AM_y2dys7.png)
370
371 In the form that opens, you can either choose to start with a blank template or from an existing design. You can then use the drag-and-drop or code editor to design the email template.
372
373 You can also use the following template as an example:
374
375 ```html title="Abandoned Cart Email Template"
376 <!DOCTYPE html>
377 <html>
378 <head>
379 <meta charset="UTF-8">
380 <meta name="viewport" content="width=device-width, initial-scale=1">
381 <title>Complete Your Purchase</title>
382 <style>
383 body {
384 font-family: Arial, sans-serif;
385 background-color: #f8f9fa;
386 margin: 0;
387 padding: 20px;
388 }
389 .container {
390 max-width: 600px;
391 background: #ffffff;
392 padding: 20px;
393 border-radius: 10px;
394 box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.1);
395 text-align: center;
396 }
397 .header {
398 font-size: 26px;
399 font-weight: bold;
400 color: #333;
401 margin-bottom: 20px;
402 }
403 .message {
404 font-size: 16px;
405 color: #555;
406 margin-bottom: 20px;
407 }
408 .item {
409 display: flex;
410 align-items: center;
411 background: #f9f9f9;
412 padding: 10px;
413 border-radius: 8px;
414 margin-bottom: 15px;
415 }
416 .item img {
417 width: 80px;
418 height: auto;
419 margin-right: 15px;
420 border-radius: 5px;
421 }
422 .item-details {
423 text-align: left;
424 flex-grow: 1;
425 }
426 .item-details strong {
427 font-size: 18px;
428 color: #333;
429 }
430 .item-details p {
431 font-size: 14px;
432 color: #777;
433 margin: 5px 0;
434 }
435 .button {
436 display: inline-block;
437 background-color: #007bff;
438 color: #ffffff;
439 text-decoration: none;
440 font-size: 18px;
441 padding: 12px 20px;
442 border-radius: 5px;
443 margin-top: 20px;
444 transition: background 0.3s ease;
445 }
446 .button:hover {
447 background-color: #0056b3;
448 }
449 .footer {
450 font-size: 12px;
451 color: #888;
452 margin-top: 20px;
453 }
454 </style>
455 </head>
456 <body>
457 <div class="container">
458 <div class="header">Hi {{customer.first_name}}, your cart is waiting! 🛍️</div>
459 <p class="message">You left some great items in your cart. Complete your purchase before they're gone!</p>
460
461 {{#each items}}
462 <div class="item">
463 <img src="{{thumbnail}}" alt="{{product_title}}">
464 <div class="item-details">
465 <strong>{{product_title}}</strong>
466 <p>{{subtitle}}</p>
467 <p>Quantity: <strong>{{quantity}}</strong></p>
468 <p>Price: <strong>$ {{unit_price}}</strong></p>
469 </div>
470 </div>
471 {{/each}}
472
473 <a href="https://yourstore.com/cart/recover/{{cart_id}}" class="button">Return to Cart & Checkout</a>
474 <p class="footer">Need help? <a href="mailto:support@yourstore.com">Contact us</a></p>
475 </div>
476 </body>
477 </html>
478 ```
479
480 This template will show each item's image, title, quantity, and price in the cart. It will also show a button to return to the cart and checkout.
481
482 You can replace `https://yourstore.com` with your storefront's URL. You'll later implement the `/cart/recover/:cart_id` route in the storefront to recover the cart.
483
484 Once you are done, copy the template ID from SendGrid and set it as an environment variable in your Medusa project:
485
486 ```plain
487 ABANDONED_CART_TEMPLATE_ID=your-sendgrid-template-id
488 ```
489
490 ---
491
492 ## Step 4: Schedule Cart Abandonment Notifications
493
494 The next step is to automate sending the abandoned cart notifications. You need a task that runs once a day to find the carts that have been abandoned for a certain period and send the notifications to the customers.
495
496 To run a task at a scheduled interval, you can use a [scheduled job](!docs!/learn/fundamentals/scheduled-jobs). A scheduled job is an asynchronous function that the Medusa application runs at the interval you specify during the Medusa application's runtime.
497
498 You can create a scheduled job in a TypeScript or JavaScript file under the `src/jobs` directory. So, to create the scheduled job that sends the abandoned cart notifications, create the file `src/jobs/send-abandoned-cart-notification.ts` with the following content:
499
500 ```ts title="src/jobs/send-abandoned-cart-notification.ts"
501 import { MedusaContainer } from "@medusajs/framework/types"
502 import {
503 sendAbandonedCartsWorkflow,
504 SendAbandonedCartsWorkflowInput,
505 } from "../workflows/send-abandoned-carts"
506 import {
507 ContainerRegistrationKeys,
508 } from "@medusajs/framework/utils"
509
510 export default async function abandonedCartJob(
511 container: MedusaContainer
512 ) {
513 const logger = container.resolve(
514 ContainerRegistrationKeys.LOGGER
515 )
516 const query = container.resolve(
517 ContainerRegistrationKeys.QUERY
518 )
519
520 const oneDayAgo = new Date()
521 oneDayAgo.setDate(oneDayAgo.getDate() - 1)
522 const limit = 100
523 const offset = 0
524 const totalCount = 0
525 const abandonedCartsCount = 0
526
527 do {
528 // TODO retrieve paginated abandoned carts
529 } while (offset < totalCount)
530
531 logger.info(`Sent ${abandonedCartsCount} abandoned cart notifications`)
532 }
533
534 export const config = {
535 name: "abandoned-cart-notification",
536 schedule: "0 0 * * *", // Run at midnight every day
537 }
538 ```
539
540 In a scheduled job's file, you must export:
541
542 1. An asynchronous function that holds the job's logic. The function receives the [Medusa container](!docs!/learn/fundamentals/medusa-container) as a parameter.
543 2. A `config` object that specifies the job's name and schedule. The schedule is a [cron expression](https://crontab.guru/) that defines the interval at which the job runs.
544
545 In the scheduled job function, so far you resolve the [Logger](!docs!/learn/debugging-and-testing/logging) to log messages, and [Query](!docs!/learn/fundamentals/query) to retrieve data across modules.
546
547 You also define a `oneDayAgo` date, which is the date that you will use as the condition of an abandoned cart. In addition, you define variables to paginate the carts.
548
549 Next, you will retrieve the abandoned carts using Query. Replace the `TODO` with the following:
550
551 ```ts title="src/jobs/send-abandoned-cart-notification.ts"
552 const {
553 data: abandonedCarts,
554 metadata,
555 } = await query.graph({
556 entity: "cart",
557 fields: [
558 "id",
559 "email",
560 "items.*",
561 "metadata",
562 "customer.*",
563 ],
564 filters: {
565 updated_at: {
566 $lt: oneDayAgo,
567 },
568 email: {
569 $ne: null,
570 },
571 completed_at: null,
572 },
573 pagination: {
574 skip: offset,
575 take: limit,
576 },
577 })
578
579 totalCount = metadata?.count ?? 0
580 const cartsWithItems = abandonedCarts.filter((cart) =>
581 cart.items?.length > 0 && !cart.metadata?.abandoned_notification
582 )
583
584 try {
585 await sendAbandonedCartsWorkflow(container).run({
586 input: {
587 carts: cartsWithItems,
588 } as unknown as SendAbandonedCartsWorkflowInput,
589 })
590 abandonedCartsCount += cartsWithItems.length
591
592 } catch (error) {
593 logger.error(
594 `Failed to send abandoned cart notification: ${error.message}`
595 )
596 }
597
598 offset += limit
599 ```
600
601 In the do-while loop, you use Query to retrieve carts matching the following criteria:
602
603 - The cart was last updated more than a day ago.
604 - The cart has an email address.
605 - The cart has not been completed.
606
607 You also filter the retrieved carts to only include carts with items and customers that have not received an abandoned cart notification.
608
609 Finally, you execute the `sendAbandonedCartsWorkflow` passing it the abandoned carts as an input. You will execute the workflow for each paginated batch of carts.
610
611 ### Test it Out
612
613 To test out the scheduled job and workflow, it is recommended to change the `oneDayAgo` date to a minute before now for easy testing:
614
615 ```ts title="src/jobs/send-abandoned-cart-notification.ts"
616 oneDayAgo.setMinutes(oneDayAgo.getMinutes() - 1) // For testing
617 ```
618
619 And to change the job's schedule in `config` to run every minute:
620
621 ```ts title="src/jobs/send-abandoned-cart-notification.ts"
622 export const config = {
623 // ...
624 schedule: "* * * * *", // Run every minute for testing
625 }
626 ```
627
628 Finally, start the Medusa application with the following command:
629
630 ```bash npm2yarn
631 npm run dev
632 ```
633
634 And in the [Next.js Starter Storefront](../../../nextjs-starter/page.mdx)'s directory (that you installed in the first step), start the storefront with the following command:
635
636 ```bash npm2yarn
637 npm run dev
638 ```
639
640 Open the storefront at `localhost:8000`. You can either:
641
642 - Create an account and add items to the cart, then leave the cart for a minute.
643 - Add an item to the cart as a guest. Then, start the checkout process, but only enter the shipping and email addresses, and leave the cart for a minute.
644
645 Afterwards, wait for the job to execute. Once it is executed, you will see the following message in the terminal:
646
647 ```bash
648 info: Sent 1 abandoned cart notifications
649 ```
650
651 Once you're done testing, make sure to revert the changes to the `oneDayAgo` date and the job's schedule.
652
653 ---
654
655 ## Step 5: Recover Cart in Storefront
656
657 In the storefront, you need to add a route that recovers the cart when the customer clicks on the link in the email. The route should receive the cart ID, set the cart ID in the cookie, and redirect the customer to the cart page.
658
659 To implement the route, in the Next.js Starter Storefront create the file `src/app/[countryCode]/(main)/cart/recover/[id]/route.tsx` with the following content:
660
661 ```tsx title="src/app/[countryCode]/(main)/cart/recover/[id]/route.tsx" badgeLabel="Storefront" badgeColor="blue"
662 import { NextRequest } from "next/server"
663 import { retrieveCart } from "../../../../../../lib/data/cart"
664 import { setCartId } from "../../../../../../lib/data/cookies"
665 import { notFound, redirect } from "next/navigation"
666 type Params = Promise<{
667 id: string
668 }>
669
670 export async function GET(req: NextRequest, { params }: { params: Params }) {
671 const { id } = await params
672 const cart = await retrieveCart(id)
673
674 if (!cart) {
675 return notFound()
676 }
677
678 setCartId(id)
679
680 const countryCode = cart.shipping_address?.country_code ||
681 cart.region?.countries?.[0]?.iso_2
682
683 redirect(
684 `/${countryCode ? `${countryCode}/` : ""}cart`
685 )
686 }
687 ```
688
689 You add a `GET` route handler that receives the cart ID as a path parameter. In the route handler, you:
690
691 - Try to retrieve the cart from the Medusa application. The `retrieveCart` function is already available in the Next.js Starter Storefront. If the cart is not found, you return a 404 response.
692 - Set the cart ID in a cookie using the `setCartId` function. This is also a function that is already available in the storefront.
693 - Redirect the customer to the cart page. You set the country code in the URL based on the cart's shipping address or region.
694
695 ### Test it Out
696
697 To test it out, start the Medusa application:
698
699 ```bash npm2yarn
700 npm run dev
701 ```
702
703 And in the Next.js Starter Storefront's directory, start the storefront:
704
705 ```bash npm2yarn
706 npm run dev
707 ```
708
709 Then, either open the link in an abandoned cart email or navigate to `localhost:8000/cart/recover/:cart_id` in your browser. You will be redirected to the cart page with the recovered cart.
710
711 ![Cart page in the storefront](https://res.cloudinary.com/dza7lstvk/image/upload/v1742459552/Medusa%20Resources/Screenshot_2025-03-20_at_10.32.17_AM_frmbup.png)
712
713 ---
714
715 ## Next Steps
716
717 You have now implemented the logic to send abandoned cart notifications in Medusa. You can implement other customizations with Medusa, such as:
718
719 - [Implement Product Reviews](../product-reviews/page.mdx).
720 - [Implement Wishlist](../../../plugins/guides/wishlist/page.mdx).
721 - [Allow Custom-Item Pricing](../../../examples/guides/custom-item-price/page.mdx).
722
723 If you are new to Medusa, check out the [main documentation](!docs!/learn), where you will get a more in-depth learning of all the concepts you have used in this guide and more.
724
725 To learn more about the commerce features that Medusa provides, check out Medusa's [Commerce Modules](../../../commerce-modules/page.mdx).