소스 검색

fix(core): Fix shipping price when the promotion is not applicable anymore (#1150)

Huseyin ALP 4 년 전
부모
커밋
eb1dcc4115

+ 4 - 0
packages/core/src/entity/shipping-line/shipping-line.entity.ts

@@ -88,6 +88,10 @@ export class ShippingLine extends VendureEntity {
         this.adjustments = this.adjustments.concat(adjustment);
     }
 
+    removeAdjustments() {
+        this.adjustments = [];
+    }
+
     /**
      * @description
      * The total of all price adjustments. Will typically be a negative number due to discounts.

+ 5 - 0
packages/core/src/service/helpers/order-calculator/order-calculator.ts

@@ -364,6 +364,11 @@ export class OrderCalculator {
                     }
                 }
             }
+        } else {
+            // If there is no applicable promotion for shipping, we should remove already assigned adjustment from shipping lines.
+            for (const shippingLine of order.shippingLines) {
+                shippingLine.removeAdjustments();
+            }
         }
     }