From 992100f1451f6e2c7bcd79bf243043d2add3e4cd Mon Sep 17 00:00:00 2001 From: Franck Allimant Date: Thu, 12 Jun 2014 16:40:07 +0200 Subject: [PATCH] Added helper to chek if number of uses is reached --- core/lib/Thelia/Model/Coupon.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/core/lib/Thelia/Model/Coupon.php b/core/lib/Thelia/Model/Coupon.php index 921078eda..616a7d040 100644 --- a/core/lib/Thelia/Model/Coupon.php +++ b/core/lib/Thelia/Model/Coupon.php @@ -41,6 +41,9 @@ use Thelia\Model\Tools\ModelEventDispatcherTrait; class Coupon extends BaseCoupon { + // Define the value of an unlimited coupon usage. + const UNLIMITED_COUPON_USE = -1; + use ModelEventDispatcherTrait; /** @@ -265,6 +268,9 @@ class Coupon extends BaseCoupon return CouponModuleQuery::create()->filterByCouponId($this->getId())->find(); } + public function isUsageUnlimited() { + return $this->getMaxUsage() == self::UNLIMITED_COUPON_USE; + } /** * Get coupon usage left, either overall, or per customer. *