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#
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#
promotionCodesToApply
string[]
The promotion codes to be applied on the cart.
The items and shipping methods of the cart.
options
Record<string, any>Optional
Any relevant options that may change how the actions are computed.
Returns#
The list of computed actions to be applied on the cart.