Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Fix apply_once_per_order in voucher

fowczarekc24bfa53c45c
diff --git a/saleor/discount/utils.py b/saleor/discount/utils.py
index e017d1b423..5915e05f07 100644
--- a/saleor/discount/utils.py
+++ b/saleor/discount/utils.py
@@ -5,7 +5,7 @@ from typing import Iterable
from django.db.models import F
from django.utils.translation import pgettext
-from ..core.utils.taxes import ZERO_MONEY, ZERO_TAXED_MONEY
+from ..core.utils.taxes import ZERO_MONEY
from . import DiscountInfo
from .models import NotApplicable, Sale
@@ -76,8 +76,7 @@ def get_shipping_voucher_discount(voucher, total_price, shipping_price):
def get_products_voucher_discount(voucher, prices):
"""Calculate discount value for a voucher of product or category type."""
if voucher.apply_once_per_order:
- product_total = sum(prices, ZERO_TAXED_MONEY)
- return voucher.get_discount_amount_for(product_total)
+ return voucher.get_discount_amount_for(min(prices))
discounts = (voucher.get_discount_amount_for(price) for price in prices)
total_amount = sum(discounts, ZERO_MONEY)
return total_amount