Skip to content

Commit

Permalink
fix(core): remove maxDiscountAmount method to PromotionItemActionConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
Feelw00 committed Jul 23, 2024
1 parent 92c2655 commit 638fe13
Showing 1 changed file with 0 additions and 41 deletions.
41 changes: 0 additions & 41 deletions packages/core/src/config/promotion/promotion-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,14 +211,6 @@ export interface PromotionItemActionConfig<T extends ConfigArgs, U extends Promo
* the OrderLine, i.e. the number should be negative.
*/
execute: ExecutePromotionItemActionFn<T, U>;

/**
* @description
* The maximum discount amount that can be applied to this action.
*
* @default 0
*/
maxDiscountAmount?: ExecutePromotionItemActionFn<T, U>;
}

/**
Expand Down Expand Up @@ -343,15 +335,10 @@ export class PromotionItemAction<
T extends ConfigArgs = ConfigArgs,
U extends Array<PromotionCondition<any>> = [],
> extends PromotionAction<T, U> {
/** @internal */
private readonly executeFn: ExecutePromotionItemActionFn<T, U>;
/** @internal */
private readonly maxDiscountAmountFn: ExecutePromotionItemActionFn<T, U>;

constructor(config: PromotionItemActionConfig<T, U>) {
super(config);
this.executeFn = config.execute;
this.maxDiscountAmountFn = config.maxDiscountAmount || (() => 0);
}

/** @internal */
Expand All @@ -376,34 +363,6 @@ export class PromotionItemAction<
promotion,
);
}

/**
* @description
* The maximum discount amount that can be applied to this action.
*
* @default 0
*/
maxDiscountAmount(
ctx: RequestContext,
orderLine: OrderLine,
args: ConfigArg[],
state: PromotionState,
promotion: Promotion,
) {
const actionState = this.conditions
? pick(
state,
this.conditions.map(c => c.code),
)
: {};
return this.maxDiscountAmountFn(
ctx,
orderLine,
this.argsArrayToHash(args),
actionState as ConditionState<U>,
promotion,
);
}
}

/**
Expand Down

0 comments on commit 638fe13

Please sign in to comment.