---
title: "Promotion Action"
generated: true
---
<GenerationInfo sourceFile="packages/core/src/config/promotion/promotion-action.ts" sourceLine="281" packageName="@vendure/core" />

An abstract class which is extended by <DocsLink href="/reference/typescript-api/promotions/promotion-action#promotionitemaction">PromotionItemAction</DocsLink>, <DocsLink href="/reference/typescript-api/promotions/promotion-action#promotionorderaction">PromotionOrderAction</DocsLink>,
and <DocsLink href="/reference/typescript-api/promotions/promotion-action#promotionshippingaction">PromotionShippingAction</DocsLink>.

```ts title="Signature"
class PromotionAction<T extends ConfigArgs = ConfigArgs, U extends PromotionCondition[] | undefined = any> extends ConfigurableOperationDef<T> {
    readonly priorityValue: number;
    constructor(config: PromotionActionConfig<T, U>)
}
```
* Extends: <DocsLink href="/reference/typescript-api/configurable-operation-def/#configurableoperationdef">`ConfigurableOperationDef`</DocsLink><T>



<div className="members-wrapper">

### priorityValue

<MemberInfo kind="property" type={`number`} default={`0`}   />

Used to determine the order of application of multiple Promotions
on the same Order. See the <DocsLink href="/reference/typescript-api/entities/promotion#promotion">Promotion</DocsLink> `priorityScore` field for
more information.
### constructor

<MemberInfo kind="method" type={`(config: <a href='/reference/typescript-api/promotions/promotion-action#promotionactionconfig'>PromotionActionConfig</a><T, U>) => PromotionAction`}   />




</div>
<GenerationInfo sourceFile="packages/core/src/config/promotion/promotion-action.ts" sourceLine="354" packageName="@vendure/core" />

Represents a PromotionAction which applies to individual <DocsLink href="/reference/typescript-api/entities/order-line#orderline">OrderLine</DocsLink>s.

*Example*

```ts
// Applies a percentage discount to each OrderLine
const itemPercentageDiscount = new PromotionItemAction({
    code: 'item_percentage_discount',
    args: { discount: 'percentage' },
    execute(ctx, orderLine, args) {
        return -orderLine.unitPrice * (args.discount / 100);
    },
    description: 'Discount every item by { discount }%',
});
```

```ts title="Signature"
class PromotionItemAction<T extends ConfigArgs = ConfigArgs, U extends Array<PromotionCondition<any>> = []> extends PromotionAction<T, U> {
    constructor(config: PromotionItemActionConfig<T, U>)
}
```
* Extends: <DocsLink href="/reference/typescript-api/promotions/promotion-action#promotionaction">`PromotionAction`</DocsLink><T, U>



<div className="members-wrapper">

### constructor

<MemberInfo kind="method" type={`(config: <a href='/reference/typescript-api/promotions/promotion-action#promotionitemactionconfig'>PromotionItemActionConfig</a><T, U>) => PromotionItemAction`}   />




</div>
<GenerationInfo sourceFile="packages/core/src/config/promotion/promotion-action.ts" sourceLine="464" packageName="@vendure/core" />

Represents a PromotionAction which applies to the <DocsLink href="/reference/typescript-api/entities/order#order">Order</DocsLink> as a whole.

*Example*

```ts
// Applies a percentage discount to the entire Order
const orderPercentageDiscount = new PromotionOrderAction({
    code: 'order_percentage_discount',
    args: { discount: 'percentage' },
    execute(ctx, order, args) {
        return -order.subTotal * (args.discount / 100);
    },
    description: 'Discount order by { discount }%',
});
```

```ts title="Signature"
class PromotionOrderAction<T extends ConfigArgs = ConfigArgs, U extends PromotionCondition[] = []> extends PromotionAction<T, U> {
    constructor(config: PromotionOrderActionConfig<T, U>)
}
```
* Extends: <DocsLink href="/reference/typescript-api/promotions/promotion-action#promotionaction">`PromotionAction`</DocsLink><T, U>



<div className="members-wrapper">

### constructor

<MemberInfo kind="method" type={`(config: <a href='/reference/typescript-api/promotions/promotion-action#promotionorderactionconfig'>PromotionOrderActionConfig</a><T, U>) => PromotionOrderAction`}   />




</div>
<GenerationInfo sourceFile="packages/core/src/config/promotion/promotion-action.ts" sourceLine="506" packageName="@vendure/core" />

Represents a PromotionAction which applies to the shipping cost of an Order.

```ts title="Signature"
class PromotionShippingAction<T extends ConfigArgs = ConfigArgs, U extends PromotionCondition[] = []> extends PromotionAction<T, U> {
    constructor(config: PromotionShippingActionConfig<T, U>)
}
```
* Extends: <DocsLink href="/reference/typescript-api/promotions/promotion-action#promotionaction">`PromotionAction`</DocsLink><T, U>



<div className="members-wrapper">

### constructor

<MemberInfo kind="method" type={`(config: <a href='/reference/typescript-api/promotions/promotion-action#promotionshippingactionconfig'>PromotionShippingActionConfig</a><T, U>) => PromotionShippingAction`}   />




</div>
<GenerationInfo sourceFile="packages/core/src/config/promotion/promotion-action.ts" sourceLine="72" packageName="@vendure/core" />

The function which is used by a PromotionItemAction to calculate the
discount on the OrderLine for each item.

```ts title="Signature"
type ExecutePromotionItemActionFn<T extends ConfigArgs, U extends Array<PromotionCondition<any>>> = (
    ctx: RequestContext,
    orderLine: OrderLine,
    args: ConfigArgValues<T>,
    state: ConditionState<U>,
    promotion: Promotion,
) => number | Promise<number>
```
<GenerationInfo sourceFile="packages/core/src/config/promotion/promotion-action.ts" sourceLine="88" packageName="@vendure/core" />

The function which is used by a PromotionLineAction to calculate the
discount on the OrderLine.

```ts title="Signature"
type ExecutePromotionLineActionFn<T extends ConfigArgs, U extends Array<PromotionCondition<any>>> = (
    ctx: RequestContext,
    orderLine: OrderLine,
    args: ConfigArgValues<T>,
    state: ConditionState<U>,
    promotion: Promotion,
) => number | Promise<number>
```
<GenerationInfo sourceFile="packages/core/src/config/promotion/promotion-action.ts" sourceLine="104" packageName="@vendure/core" />

The function which is used by a PromotionOrderAction to calculate the
discount on the Order.

```ts title="Signature"
type ExecutePromotionOrderActionFn<T extends ConfigArgs, U extends Array<PromotionCondition<any>>> = (
    ctx: RequestContext,
    order: Order,
    args: ConfigArgValues<T>,
    state: ConditionState<U>,
    promotion: Promotion,
) => number | Promise<number>
```
<GenerationInfo sourceFile="packages/core/src/config/promotion/promotion-action.ts" sourceLine="120" packageName="@vendure/core" />

The function which is used by a PromotionOrderAction to calculate the
discount on the Order.

```ts title="Signature"
type ExecutePromotionShippingActionFn<T extends ConfigArgs, U extends Array<PromotionCondition<any>>> = (
    ctx: RequestContext,
    shippingLine: ShippingLine,
    order: Order,
    args: ConfigArgValues<T>,
    state: ConditionState<U>,
    promotion: Promotion,
) => number | Promise<number>
```
<GenerationInfo sourceFile="packages/core/src/config/promotion/promotion-action.ts" sourceLine="141" packageName="@vendure/core" since="1.8.0" experimental="true" />

The signature of a PromotionAction's side-effect functions `onActivate` and `onDeactivate`.

```ts title="Signature"
type PromotionActionSideEffectFn<T extends ConfigArgs> = (
    ctx: RequestContext,
    order: Order,
    args: ConfigArgValues<T>,
    promotion: Promotion,
) => void | Promise<void>
```
<GenerationInfo sourceFile="packages/core/src/config/promotion/promotion-action.ts" sourceLine="155" packageName="@vendure/core" />

Configuration for all types of <DocsLink href="/reference/typescript-api/promotions/promotion-action#promotionaction">PromotionAction</DocsLink>.

```ts title="Signature"
interface PromotionActionConfig<T extends ConfigArgs, U extends Array<PromotionCondition<any>> | undefined> extends ConfigurableOperationDefOptions<T> {
    priorityValue?: number;
    conditions?: U extends undefined ? undefined : ConditionTuple<Exclude<U, undefined>>;
    onActivate?: PromotionActionSideEffectFn<T>;
    onDeactivate?: PromotionActionSideEffectFn<T>;
}
```
* Extends: <DocsLink href="/reference/typescript-api/configurable-operation-def/configurable-operation-def-options#configurableoperationdefoptions">`ConfigurableOperationDefOptions`</DocsLink><T>



<div className="members-wrapper">

### priorityValue

<MemberInfo kind="property" type={`number`} default={`0`}   />

Used to determine the order of application of multiple Promotions
on the same Order. See the <DocsLink href="/reference/typescript-api/entities/promotion#promotion">Promotion</DocsLink> `priorityScore` field for
more information.
### conditions

<MemberInfo kind="property" type={`U extends undefined ? undefined : ConditionTuple<Exclude<U, undefined>>`}   />

Allows PromotionActions to define one or more PromotionConditions as dependencies. Having a PromotionCondition
as a dependency has the following consequences:
1. A Promotion using this PromotionAction is only valid if it also contains all PromotionConditions
on which it depends.
2. The `execute()` function will receive a statically-typed `state` argument which will contain
the return values of the PromotionConditions' `check()` function.
### onActivate

<MemberInfo kind="property" type={`<a href='/reference/typescript-api/promotions/promotion-action#promotionactionsideeffectfn'>PromotionActionSideEffectFn</a><T>`}  since="1.8.0" experimental="true" />

An optional side effect function which is invoked when the promotion
becomes active. It can be used for things like adding a free gift to the order
or other side effects that are unrelated to price calculations.

If used, make sure to use the corresponding `onDeactivate` function to clean up
or reverse any side effects as needed.
### onDeactivate

<MemberInfo kind="property" type={`<a href='/reference/typescript-api/promotions/promotion-action#promotionactionsideeffectfn'>PromotionActionSideEffectFn</a><T>`}  since="1.8.0" experimental="true" />

Used to reverse or clean up any side effects executed as part of the `onActivate` function.


</div>
<GenerationInfo sourceFile="packages/core/src/config/promotion/promotion-action.ts" sourceLine="209" packageName="@vendure/core" />

Configuration for a <DocsLink href="/reference/typescript-api/promotions/promotion-action#promotionitemaction">PromotionItemAction</DocsLink>

```ts title="Signature"
interface PromotionItemActionConfig<T extends ConfigArgs, U extends PromotionCondition[]> extends PromotionActionConfig<T, U> {
    execute: ExecutePromotionItemActionFn<T, U>;
}
```
* Extends: <DocsLink href="/reference/typescript-api/promotions/promotion-action#promotionactionconfig">`PromotionActionConfig`</DocsLink><T, U>



<div className="members-wrapper">

### execute

<MemberInfo kind="property" type={`<a href='/reference/typescript-api/promotions/promotion-action#executepromotionitemactionfn'>ExecutePromotionItemActionFn</a><T, U>`}   />

The function which contains the promotion calculation logic.
Should resolve to a number which represents the amount by which to discount
the OrderLine, i.e. the number should be negative.


</div>
<GenerationInfo sourceFile="packages/core/src/config/promotion/promotion-action.ts" sourceLine="227" packageName="@vendure/core" />

Configuration for a <DocsLink href="/reference/typescript-api/promotions/promotion-action#promotionlineaction">PromotionLineAction</DocsLink>

```ts title="Signature"
interface PromotionLineActionConfig<T extends ConfigArgs, U extends PromotionCondition[]> extends PromotionActionConfig<T, U> {
    execute: ExecutePromotionLineActionFn<T, U>;
}
```
* Extends: <DocsLink href="/reference/typescript-api/promotions/promotion-action#promotionactionconfig">`PromotionActionConfig`</DocsLink><T, U>



<div className="members-wrapper">

### execute

<MemberInfo kind="property" type={`<a href='/reference/typescript-api/promotions/promotion-action#executepromotionlineactionfn'>ExecutePromotionLineActionFn</a><T, U>`}   />

The function which contains the promotion calculation logic.
Should resolve to a number which represents the amount by which to discount
the OrderLine, i.e. the number should be negative.


</div>
<GenerationInfo sourceFile="packages/core/src/config/promotion/promotion-action.ts" sourceLine="244" packageName="@vendure/core" />



```ts title="Signature"
interface PromotionOrderActionConfig<T extends ConfigArgs, U extends PromotionCondition[]> extends PromotionActionConfig<T, U> {
    execute: ExecutePromotionOrderActionFn<T, U>;
}
```
* Extends: <DocsLink href="/reference/typescript-api/promotions/promotion-action#promotionactionconfig">`PromotionActionConfig`</DocsLink><T, U>



<div className="members-wrapper">

### execute

<MemberInfo kind="property" type={`<a href='/reference/typescript-api/promotions/promotion-action#executepromotionorderactionfn'>ExecutePromotionOrderActionFn</a><T, U>`}   />

The function which contains the promotion calculation logic.
Should resolve to a number which represents the amount by which to discount
the Order, i.e. the number should be negative.


</div>
<GenerationInfo sourceFile="packages/core/src/config/promotion/promotion-action.ts" sourceLine="261" packageName="@vendure/core" />



```ts title="Signature"
interface PromotionShippingActionConfig<T extends ConfigArgs, U extends PromotionCondition[]> extends PromotionActionConfig<T, U> {
    execute: ExecutePromotionShippingActionFn<T, U>;
}
```
* Extends: <DocsLink href="/reference/typescript-api/promotions/promotion-action#promotionactionconfig">`PromotionActionConfig`</DocsLink><T, U>



<div className="members-wrapper">

### execute

<MemberInfo kind="property" type={`<a href='/reference/typescript-api/promotions/promotion-action#executepromotionshippingactionfn'>ExecutePromotionShippingActionFn</a><T, U>`}   />

The function which contains the promotion calculation logic.
Should resolve to a number which represents the amount by which to discount
the Shipping, i.e. the number should be negative.


</div>
<GenerationInfo sourceFile="packages/core/src/config/promotion/promotion-action.ts" sourceLine="409" packageName="@vendure/core" />

Represents a PromotionAction which applies to individual <DocsLink href="/reference/typescript-api/entities/order-line#orderline">OrderLine</DocsLink>s.
The difference from PromotionItemAction is that it applies regardless of the Quantity of the OrderLine.

*Example*

```ts
// Applies a percentage discount to each OrderLine
const linePercentageDiscount = new PromotionLineAction({
    code: 'line_percentage_discount',
    args: { discount: 'percentage' },
    execute(ctx, orderLine, args) {
        return -orderLine.linePrice * (args.discount / 100);
    },
    description: 'Discount every line by { discount }%',
});
```

```ts title="Signature"
class PromotionLineAction<T extends ConfigArgs = ConfigArgs, U extends Array<PromotionCondition<any>> = []> extends PromotionAction<T, U> {
    constructor(config: PromotionLineActionConfig<T, U>)
}
```
* Extends: <DocsLink href="/reference/typescript-api/promotions/promotion-action#promotionaction">`PromotionAction`</DocsLink><T, U>



<div className="members-wrapper">

### constructor

<MemberInfo kind="method" type={`(config: <a href='/reference/typescript-api/promotions/promotion-action#promotionlineactionconfig'>PromotionLineActionConfig</a><T, U>) => PromotionLineAction`}   />




</div>
