Parcourir la source

fix(core): Correctly calculate item price discount actions

Was not taking into account existing promotions previously.
Michael Bromley il y a 5 ans
Parent
commit
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) {
         if (await facetValueChecker.hasFacetValues(orderLine, args.facets)) {
-            return -orderLine.unitPrice * (args.discount / 100);
+            return -orderItem.unitPriceWithPromotions * (args.discount / 100);
         }
         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) {
         if (lineContainsIds(args.productVariantIds, orderLine)) {
-            return -orderLine.unitPrice * (args.discount / 100);
+            return -orderItem.unitPriceWithPromotions * (args.discount / 100);
         }
         return 0;
     },