Development Resources

computeActions - Promotion Module Reference

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

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?