Back to Medusa

ComputeActionContext

www/apps/resources/references/promotion/interfaces/promotion.ComputeActionContext/page.mdx

2.14.28.7 KB
Original Source

import { TypeList } from "docs-ui"

ComputeActionContext

The context provided when computing actions of promotions.

<TypeList types={[{"name":"currency_code","type":"string","description":"The cart's currency","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customer","type":"object","description":"The customer associated with the cart.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"string","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"groups","type":"object[]","description":"The customer groups the customer belongs to.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"string","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]},{"name":"region","type":"object","description":"The region associated with the cart.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"string","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"shipping_address","type":"object","description":"The shipping address associated with the cart.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"country_code","type":"string","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"sales_channel_id","type":"string","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"email","type":"string","description":"The cart's email","optional":true,"defaultValue":"","expandable":false,"children":[],"since":"2.11.0"},{"name":"items","type":"ComputeActionItemLine[]","description":"The cart's line items.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"string","description":"The ID of the item line.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"quantity","type":"BigNumberInput","description":"The quantity of the line item.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"value","type":"string \| number","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"numeric","type":"number","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"BigNumberRawValue","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"BigNumber","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"subtotal","type":"BigNumberInput","description":"The subtotal of the line item.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"value","type":"string \| number","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"numeric","type":"number","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"BigNumberRawValue","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"BigNumber","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"original_total","type":"BigNumberInput","description":"The total of the line item.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"value","type":"string \| number","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"numeric","type":"number","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"BigNumberRawValue","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"BigNumber","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"is_discountable","type":"boolean","description":"Whether the line item is discountable.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"adjustments","type":"ComputeActionAdjustmentLine[]","description":"The adjustments applied before on the line item.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"string","description":"The ID of the compute action's adjustment line.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"code","type":"string","description":"The promotion's code.","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"product","type":"object","description":"The product ID of the line item. Our default promotion rules rely on the product ID to apply the promotion.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"string","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"collection_id","type":"string","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"tags","type":"object[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"categories","type":"object[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"type_id","type":"string","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]},{"name":"shipping_methods","type":"ComputeActionShippingLine[]","description":"The cart's shipping methods.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"string","description":"The ID of the shipping method.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"subtotal","type":"BigNumberInput","description":"The subtotal of the shipping method.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"value","type":"string \| number","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"numeric","type":"number","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"BigNumberRawValue","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"BigNumber","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"original_total","type":"BigNumberInput","description":"The total of the shipping method.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"value","type":"string \| number","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"numeric","type":"number","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw","type":"BigNumberRawValue","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"bigNumber","type":"BigNumber","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"adjustments","type":"ComputeActionAdjustmentLine[]","description":"The adjustments applied before on the shipping method.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"string","description":"The ID of the compute action's adjustment line.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"code","type":"string","description":"The promotion's code.","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"shipping_option","type":"object","description":"The shipping option type associated with the shipping method.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"shipping_option_type_id","type":"string","description":"The ID of the shipping option type associated with the shipping method.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="ComputeActionContext"/>