# computeActions - Promotion Module Reference

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

You should only use this methods when implementing complex customizations. For common cases, check out [available workflows instead](https://docs.medusajs.com/medusa-workflows-reference).

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

## Example

```ts
const actions = await promotionModuleService.computeActions(
  ["50OFF"],
  {
    items: [
      {
        id: "cali_123",
        quantity: 2,
        subtotal: 1000,
      },
    ],
    shipping_methods: [
      {
        id: "casm_123",
        subtotal: 0,
        adjustments: [
          {
            id: "adj_123",
            code: "FREESHIPPING",
          },
        ],
      },
    ],
  }
)
```

## Parameters

- promotionCodesToApply: (\`string\`\[]) The promotion codes to be applied on the cart.
- applicationContext: (\[ComputeActionContext]\(../../../interfaces/promotion.ComputeActionContext/page.mdx)) The items and shipping methods of the cart.

  - currency\_code: (\`string\`) The cart's currency

  - customer: (\`object\`) The customer associated with the cart.

    - id: (\`string\`)

    - groups: (\`object\`\[]) The customer groups the customer belongs to.

  - region: (\`object\`) The region associated with the cart.

    - id: (\`string\`)

  - shipping\_address: (\`object\`) The shipping address associated with the cart.

    - country\_code: (\`string\`)

  - sales\_channel\_id: (\`string\`)

  - email: (\`string\`) The cart's email

  - items: (\[ComputeActionItemLine]\(../../../interfaces/promotion.ComputeActionItemLine/page.mdx)\[]) The cart's line items.

    - id: (\`string\`) The ID of the item line.

    - quantity: (\[BigNumberInput]\(../../../types/promotion.BigNumberInput/page.mdx)) The quantity of the line item.

    - subtotal: (\[BigNumberInput]\(../../../types/promotion.BigNumberInput/page.mdx)) The subtotal of the line item.

    - original\_total: (\[BigNumberInput]\(../../../types/promotion.BigNumberInput/page.mdx)) The total of the line item.

    - is\_discountable: (\`boolean\`) Whether the line item is discountable.

    - adjustments: (\[ComputeActionAdjustmentLine]\(../../../interfaces/promotion.ComputeActionAdjustmentLine/page.mdx)\[]) The adjustments applied before on the line item.

    - product: (\`object\`) The product ID of the line item. Our default promotion rules rely on the product ID to apply the promotion.

  - shipping\_methods: (\[ComputeActionShippingLine]\(../../../interfaces/promotion.ComputeActionShippingLine/page.mdx)\[]) The cart's shipping methods.

    - id: (\`string\`) The ID of the shipping method.

    - subtotal: (\[BigNumberInput]\(../../../types/promotion.BigNumberInput/page.mdx)) The subtotal of the shipping method.

    - original\_total: (\[BigNumberInput]\(../../../types/promotion.BigNumberInput/page.mdx)) The total of the shipping method.

    - adjustments: (\[ComputeActionAdjustmentLine]\(../../../interfaces/promotion.ComputeActionAdjustmentLine/page.mdx)\[]) The adjustments applied before on the shipping method.

    - shipping\_option: (\`object\`) The shipping option type associated with the shipping method.
- options: (\`Record\<string, any>\`) Any relevant options that may change how the actions are computed.

## Returns

- Promise: (Promise\&#60;\[ComputeActions]\(../../../types/promotion.ComputeActions/page.mdx)\[]\&#62;) The list of computed actions to be applied on the cart.

  - ComputeActions\[]: (\[ComputeActions]\(../../../types/promotion.ComputeActions/page.mdx)\[])

    - action: (\`"addItemAdjustment"\`) The type of action.

    - item\_id: (\`string\`) The associated item's ID.

    - amount: (\[BigNumberInput]\(../../../types/promotion.BigNumberInput/page.mdx)) The amount to remove off the item's total.

      - value: (\`string\` \\| \`number\`)

      - numeric: (\`number\`)

      - raw: (\[BigNumberRawValue]\(../../../types/promotion.BigNumberRawValue/page.mdx))

      - bigNumber: (\`BigNumber\`)

    - code: (\`string\`) The promotion's code.

    - adjustment\_id: (\`string\`) The associated adjustment's ID.

    - shipping\_method\_id: (\`string\`) The associated shipping method's ID.

    - is\_tax\_inclusive: (\`boolean\`) Whether the promotion amount includes tax.

    - description: (\`string\`) The promotion's description.
