computeActions - Promotion Module Reference

This documentation provides a reference to the computeActions method. This belongs to the Promotion Module.

Note: You should only use this methods when implementing complex customizations. For common cases, check out available workflows instead.

This method provides the actions to perform on a cart based on the specified promotions and context.

Example#

Code
1const actions = await promotionModuleService.computeActions(2  ["50OFF"],3  {4    items: [5      {6        id: "cali_123",7        quantity: 2,8        subtotal: 1000,9      },10    ],11    shipping_methods: [12      {13        id: "casm_123",14        subtotal: 0,15        adjustments: [16          {17            id: "adj_123",18            code: "FREESHIPPING",19          },20        ],21      },22    ],23  }24)

Parameters#

promotionCodesToApplystring[]
The promotion codes to be applied on the cart.
applicationContextComputeActionContext
The items and shipping methods of the cart.
optionsRecord<string, any>Optional
Any relevant options that may change how the actions are computed.

Returns#

PromisePromise<ComputeActions[]>
The list of computed actions to be applied on the cart.
Was this page helpful?
Ask Anything
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