Explorar o código

fix(core): Fix PromotionActions not passing state correctly (#1323)

Closes #1322
Hubert %!s(int64=4) %!d(string=hai) anos
pai
achega
fc739c50ee
Modificáronse 1 ficheiros con 2 adicións e 2 borrados
  1. 2 2
      packages/core/src/config/promotion/promotion-action.ts

+ 2 - 2
packages/core/src/config/promotion/promotion-action.ts

@@ -309,7 +309,7 @@ export class PromotionOrderAction<
 
 
     /** @internal */
     /** @internal */
     execute(ctx: RequestContext, order: Order, args: ConfigArg[], state: PromotionState) {
     execute(ctx: RequestContext, order: Order, args: ConfigArg[], state: PromotionState) {
-        const actionState = this.conditions ? pick(state, Object.keys(this.conditions)) : {};
+        const actionState = this.conditions ? pick(state, this.conditions.map(c => c.code)) : {};
         return this.executeFn(ctx, order, this.argsArrayToHash(args), actionState as ConditionState<U>);
         return this.executeFn(ctx, order, this.argsArrayToHash(args), actionState as ConditionState<U>);
     }
     }
 }
 }
@@ -340,7 +340,7 @@ export class PromotionShippingAction<
         args: ConfigArg[],
         args: ConfigArg[],
         state: PromotionState,
         state: PromotionState,
     ) {
     ) {
-        const actionState = this.conditions ? pick(state, Object.keys(this.conditions)) : {};
+        const actionState = this.conditions ? pick(state, this.conditions.map(c => c.code)) : {};
         return this.executeFn(
         return this.executeFn(
             ctx,
             ctx,
             shippingLine,
             shippingLine,