Manage Cart Promotions in Storefront

In this guide, you'll learn how to manage cart promotions or discounts, including adding, listing, and removing them.

Add Promotion to Cart#

To add a promotion to a cart, use the Add Promotion API route.

For example:

Tip: Learn how to install and configure the JS SDK in the JS SDK documentation.

The Add Promotion API route accepts the cart ID as a path parameter, and a promo_codes request body parameter, which is an array of promotion codes to apply to the cart.

The response includes the updated cart with the applied promotions. You can use this cart object to show the updated promotions to the customer.


List Cart Promotions#

The cart object you retrieve in the storefront has a promotions field, which is an array of the promotions applied to the cart.

You can refer to the API reference for the expected fields in a promotion object.

A promotion mainly has a code field. You can use that code to display the applied promotions to the customer, and later to remove a promotion from the cart.

For example, if you have a cart object retrieved from Medusa's Store APIs, you can list its promotions as follows:

Code
1<div>2  {cart?.promotions?.length ? (3    <ul>4      {cart.promotions.map((promo) => (5        <li key={promo.id}>{promo.code}6          <button onClick={() => removePromotion(promo.code!)}>Remove</button>7        </li>8      ))}9    </ul>10  ) : (11    <p>No promotions applied</p>12  )}13</div>

In the above example, you show the list of applied promotions, and for each promotion, you provide a button to remove it from the cart.

Tip: To show the total discount amount from the applied promotions, refer to the Cart Totals guide.

Remove Promotion from Cart#

To remove a promotion from a cart, use the Remove Promotion API route.

For example:

The Remove Promotion API route accepts the cart ID as a path parameter, and a promo_codes request body parameter, which is an array of promotion codes to remove from the cart.

The response includes the updated cart with the removed promotions. You can use this cart object to show the updated promotions to the customer.

Was this page helpful?
Ask Bloom
For assistance in your development, use Claude Code Plugins or Docs MCP server in Cursor, VSCode, etc...FAQ
What is Medusa?
How can I create a module?
How can I create a data model?
How do I create a workflow?
How can I extend a data model in the Product Module?
Recipes
How do I build a marketplace with Medusa?
How do I build digital products with Medusa?
How do I build subscription-based purchases with Medusa?
What other recipes are available in the Medusa documentation?
Chat is cleared on refresh
Line break
⇧↵