Promotion Actions

In this document, you’ll learn about promotion actions and how they’re computed using the computeActions method.

computeActions Method#

The Promotion Module's main service has a computeActions method that returns an array of actions to perform on a cart when one or more promotions are applied.

Actions inform you what adjustment must be made to a cart item or shipping method. Each action is an object having the action property indicating the type of action.


How Promotions Stack#

When you pass more than one promotion to computeActions, Medusa applies them one after another and returns the combined actions.

Medusa applies the promotions in the following order:

  1. buyget promotions, then standard promotions.
  2. Within each type, Medusa sorts promotions by their application method's value in descending order.

Medusa computes each promotion against the remaining amount of a line item or shipping method: its original amount minus the amount that promotions earlier in the same computation already discounted. Medusa never discounts an item below 0.

This affects how percentages are calculated. A percentage promotion applies its percentage to the remaining amount, not the original amount. For example, if a $30 discount already applied to a $200 item, a following 10% promotion discounts 10% of the remaining $170, which is $17.

Note: Medusa tracks the remaining amount within a single computeActions call. Across separate calls, Medusa reflects previously applied adjustments in the item's amount.

Order-Level Promotions#

Medusa always distributes a promotion whose application method's target_type is order across the cart's applicable items, whether its value is a percentage or a fixed amount. Medusa distributes the discount proportionally based on each item's remaining amount.

For example, consider a cart with two items:

  • Item A: $250
  • Item B: $150

If you apply a $100 fixed discount on the order, Medusa distributes it proportionally across the two items based on their share of the $400 total:

  • Item A: $100 x (250 / 400) = $62.5
  • Item B: $100 x (150 / 400) = $37.5

If another order-level promotion applies afterward, Medusa recalculates each item's share using its remaining amount ($187.5 and $112.5).


Action Types#

Found a problem with this page?Report Issue
Edited Nov 14·Edit this page