diff --git a/ajax/frontend/redeem.php b/ajax/frontend/redeem.php index e5fa5e436429af435d014928d82cb85c3e40c9a3..740b4a274404ee0bf37846d9b9b91decee7d9835 100644 --- a/ajax/frontend/redeem.php +++ b/ajax/frontend/redeem.php @@ -45,6 +45,7 @@ function ($code, $orderHash) { $calculations = $Order->getArticles()->getCalculations(); $subSum = $calculations['subSum']; + $sum = $calculations['sum']; $discounts = $CouponCode->getDiscounts(); foreach ($discounts as $Discount) { @@ -59,6 +60,21 @@ function ($code, $orderHash) { return false; } + if ($Discount->getAttribute('scope') === QUI\ERP\Discount\Handler::DISCOUNT_SCOPE_GRAND_TOTAL) { + if (!DiscountEvents::isDiscountUsableWithPurchaseValue($Discount, $sum)) { + QUI::getMessagesHandler()->addError( + QUI::getLocale()->get( + 'quiqqer/coupons', + 'exception.CouponCode.discounts_invalid' + ) + ); + + return false; + } + + continue; + } + if (!DiscountEvents::isDiscountUsableWithPurchaseValue($Discount, $subSum)) { QUI::getMessagesHandler()->addError( QUI::getLocale()->get( diff --git a/src/QUI/ERP/Coupons/Events.php b/src/QUI/ERP/Coupons/Events.php index 655b98b5b45a4dd7fb306e4f758df640ccdd0240..12c599c2e3a37651342fe7115388607392b0f651 100644 --- a/src/QUI/ERP/Coupons/Events.php +++ b/src/QUI/ERP/Coupons/Events.php @@ -252,7 +252,10 @@ public static function onQuiqqerOrderBasketToOrder( continue; } - if (!DiscountEvents::isDiscountUsableWithPurchaseValue($Discount, $subSum)) { + if ($Discount->getAttribute('scope') === QUI\ERP\Discount\Handler::DISCOUNT_SCOPE_GRAND_TOTAL) { + // do nothing for this scope + // since this scope requires all price factors etc, this cannot be calculated here + } elseif (!DiscountEvents::isDiscountUsableWithPurchaseValue($Discount, $subSum)) { continue; }