From a28854b626efc86efa2382bbe7bbc6b48fa8c66e Mon Sep 17 00:00:00 2001 From: Fabiana Romagnoli Date: Mon, 9 Dec 2024 14:34:06 +0100 Subject: [PATCH 1/2] Fix issue #4401 --- app/code/core/Mage/SalesRule/Model/Validator.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/code/core/Mage/SalesRule/Model/Validator.php b/app/code/core/Mage/SalesRule/Model/Validator.php index 144eb681e87..9bd2e0ba2f7 100644 --- a/app/code/core/Mage/SalesRule/Model/Validator.php +++ b/app/code/core/Mage/SalesRule/Model/Validator.php @@ -179,7 +179,9 @@ protected function _canProcessRule($rule, $address) return false; } // check coupon expiration - if ($coupon->hasExpirationDate() && ($coupon->getExpirationDate() < Mage::getModel('core/date')->date())) { + $couponExpirationDay = Mage::getModel('core/date')->date(Varien_Date::DATE_PHP_FORMAT, $coupon->getExpirationDate()); + $today = Mage::getModel('core/date')->date(Varien_Date::DATE_PHP_FORMAT); + if ($coupon->hasExpirationDate() && ($couponExpirationDay < $today)) { $rule->setIsValidForAddress($address, false); return false; } From 3cff24f48ab0f4e59d5ea82361fabe746368a2bf Mon Sep 17 00:00:00 2001 From: Fabiana Romagnoli Date: Thu, 2 Jan 2025 11:01:49 +0100 Subject: [PATCH 2/2] Refactor coupon expiration validation --- app/code/core/Mage/SalesRule/Model/Validator.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/code/core/Mage/SalesRule/Model/Validator.php b/app/code/core/Mage/SalesRule/Model/Validator.php index b9b44692dab..32589269987 100644 --- a/app/code/core/Mage/SalesRule/Model/Validator.php +++ b/app/code/core/Mage/SalesRule/Model/Validator.php @@ -179,9 +179,12 @@ protected function _canProcessRule($rule, $address) return false; } // check coupon expiration - $couponExpirationDay = Mage::getModel('core/date')->date(Varien_Date::DATE_PHP_FORMAT, $coupon->getExpirationDate()); + $couponExpirationDay = null; + if ($coupon->hasExpirationDate()) { + $couponExpirationDay = Mage::getModel('core/date')->date(Varien_Date::DATE_PHP_FORMAT, $coupon->getExpirationDate()); + } $today = Mage::getModel('core/date')->date(Varien_Date::DATE_PHP_FORMAT); - if ($coupon->hasExpirationDate() && ($couponExpirationDay < $today)) { + if ($couponExpirationDay !== null && ($couponExpirationDay < $today)) { $rule->setIsValidForAddress($address, false); return false; }