Fixed the checking of maximum coupon usage count

This commit is contained in:
Franck Allimant
2014-06-12 16:42:00 +02:00
parent 992100f145
commit b34f1c35c7
2 changed files with 45 additions and 40 deletions

View File

@@ -69,7 +69,7 @@ class CouponFactory
} }
// Check coupon usage count // Check coupon usage count
if ($couponModel->getUsagesLeft($this->facade->getCustomer()->getId()) <= 0) { if (! $couponModel->isUsageUnlimited() && $couponModel->getUsagesLeft($this->facade->getCustomer()->getId()) <= 0) {
throw new CouponNoUsageLeftException($couponCode); throw new CouponNoUsageLeftException($couponCode);
} }

View File

@@ -278,6 +278,10 @@ class CouponManager
*/ */
public function decrementQuantity(Coupon $coupon, $customerId = null) public function decrementQuantity(Coupon $coupon, $customerId = null)
{ {
if ($coupon->isUsageUnlimited()) {
$ret = true;
}
else {
$ret = false; $ret = false;
try { try {
@@ -330,6 +334,7 @@ class CouponManager
// Just log the problem. // Just log the problem.
Tlog::getInstance()->addError(sprintf("Failed to decrement coupon %s: %s", $coupon->getCode(), $ex->getMessage())); Tlog::getInstance()->addError(sprintf("Failed to decrement coupon %s: %s", $coupon->getCode(), $ex->getMessage()));
} }
}
return $ret; return $ret;
} }