Added helper to chek if number of uses is reached

This commit is contained in:
Franck Allimant
2014-06-12 16:40:07 +02:00
parent 96ebcf1880
commit 992100f145

View File

@@ -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.
*