Просмотр исходного кода

fix(core): Correctly calculate item price discount actions

Was not taking into account existing promotions previously.
Michael Bromley 5 лет назад
Родитель
Сommit
06bb7800b6

+ 1 - 1
packages/core/src/config/promotion/actions/facet-values-discount-action.ts

@@ -26,7 +26,7 @@ export const discountOnItemWithFacets = new PromotionItemAction({
     },
     },
     async execute(orderItem, orderLine, args) {
     async execute(orderItem, orderLine, args) {
         if (await facetValueChecker.hasFacetValues(orderLine, args.facets)) {
         if (await facetValueChecker.hasFacetValues(orderLine, args.facets)) {
-            return -orderLine.unitPrice * (args.discount / 100);
+            return -orderItem.unitPriceWithPromotions * (args.discount / 100);
         }
         }
         return 0;
         return 0;
     },
     },

+ 1 - 1
packages/core/src/config/promotion/actions/product-discount-action.ts

@@ -26,7 +26,7 @@ export const productsPercentageDiscount = new PromotionItemAction({
 
 
     execute(orderItem, orderLine, args) {
     execute(orderItem, orderLine, args) {
         if (lineContainsIds(args.productVariantIds, orderLine)) {
         if (lineContainsIds(args.productVariantIds, orderLine)) {
-            return -orderLine.unitPrice * (args.discount / 100);
+            return -orderItem.unitPriceWithPromotions * (args.discount / 100);
         }
         }
         return 0;
         return 0;
     },
     },