***

title: "OrderLineDiscountDistributionStrategy"
generated: true
---------------

## OrderLineDiscountDistributionStrategy

<GenerationInfo sourceFile="packages/core/src/config/order/order-line-discount-distribution-strategy.ts" sourceLine="45" packageName="@vendure/core" since="3.7.0" />

Determines the weight used to distribute (prorate) an order-level promotion discount across the
[OrderLine](/current/core/reference/typescript-api/entities/order-line#orderline)s of an [Order](/current/core/reference/typescript-api/entities/order#order). The weights returned for all lines are fed into the
`prorate()` helper, which splits the total order-level discount amount proportionally.

This makes it possible to control what happens to the distribution when a line is canceled or
refunded. The default strategy gives a fully-canceled line (quantity 0) a weight of 0, so its
share of the discount is redistributed across the remaining lines. A custom strategy can instead
weight lines by their originally-placed quantity, keeping each surviving line's share stable when
another line is refunded.

*Example*

```ts
// Keeps each surviving line's discount share stable when another line is
// refunded, rather than redistributing the canceled line's share onto the
// remaining lines. Suitable for unconditional order-level promotions where
// the refunded amount must reconcile with the order total.
export class PlacementStableDistributionStrategy
    implements OrderLineDiscountDistributionStrategy {
    getWeight(ctx: RequestContext, line: OrderLine, order: Order): number {
        const placedQuantity = line.orderPlacedQuantity || line.quantity;
        return line.unitPriceWithTax * placedQuantity;
    }
}
```

:::info

This is configured via the `orderOptions.orderLineDiscountDistributionStrategy` property of
your VendureConfig.

:::

```ts title="Signature"
interface OrderLineDiscountDistributionStrategy extends InjectableStrategy {
    getWeight(ctx: RequestContext, line: OrderLine, order: Order): number | Promise<number>;
}
```

* Extends: [`InjectableStrategy`](/current/core/reference/typescript-api/common/injectable-strategy#injectablestrategy)

<div className="members-wrapper">

### getWeight

\<MemberInfo kind="method" type={`(ctx: <a href='/current/core/reference/typescript-api/request/request-context#requestcontext'>RequestContext</a>, line: <a href='/current/core/reference/typescript-api/entities/order-line#orderline'>OrderLine</a>, order: <a href='/current/core/reference/typescript-api/entities/order#order'>Order</a>) => number | Promise<number>`}   />

Returns the (non-negative) weight for the given OrderLine. Returning 0 excludes the line from
receiving any share of the order-level discount.

The `order` argument provides the full Order context (e.g. the other lines, the
originally-placed quantities, the order state), allowing a custom strategy to weight a line
relative to the rest of the order rather than in isolation.

</div>
## DefaultOrderLineDiscountDistributionStrategy

<GenerationInfo sourceFile="packages/core/src/config/order/default-order-line-discount-distribution-strategy.ts" sourceLine="28" packageName="@vendure/core" since="3.7.0" />

The default [OrderLineDiscountDistributionStrategy](/current/core/reference/typescript-api/orders/order-line-discount-distribution-strategy#orderlinediscountdistributionstrategy). Weights each line by its current
prorated line price (incl. tax) and assigns zero weight to fully-canceled lines (quantity 0).
This reproduces Vendure's historical distribution behavior exactly.

This default is consistent with Vendure's promotion model, in which order-level promotions are
re-evaluated on every order modification. When an order line is canceled, its share of an
order-level discount is redistributed across the surviving lines.

Note that for **unconditional** order-level promotions (e.g. a flat "$50 off" with no minimum),
this redistribution means a partial refund reduces the order total by more than the amount
refunded, since the canceled line's discount share moves onto the retained lines. Stores that
require the discount distributions to be immutable by refunds should provide a custom strategy
that weights lines by their originally-placed quantity (see the example on
[OrderLineDiscountDistributionStrategy](/current/core/reference/typescript-api/orders/order-line-discount-distribution-strategy#orderlinediscountdistributionstrategy)).

```ts title="Signature"
class DefaultOrderLineDiscountDistributionStrategy implements OrderLineDiscountDistributionStrategy {
    getWeight(ctx: RequestContext, line: OrderLine, order: Order) => number;
}
```

* Implements: [`OrderLineDiscountDistributionStrategy`](/current/core/reference/typescript-api/orders/order-line-discount-distribution-strategy#orderlinediscountdistributionstrategy)

<div className="members-wrapper">

### getWeight

\<MemberInfo kind="method" type={`(ctx: <a href='/current/core/reference/typescript-api/request/request-context#requestcontext'>RequestContext</a>, line: <a href='/current/core/reference/typescript-api/entities/order-line#orderline'>OrderLine</a>, order: <a href='/current/core/reference/typescript-api/entities/order#order'>Order</a>) => number`}   />

</div>
