本文整理匯總了PHP中Sylius\Component\Promotion\Model\PromotionInterface::getUsageLimit方法的典型用法代碼示例。如果您正苦於以下問題:PHP PromotionInterface::getUsageLimit方法的具體用法?PHP PromotionInterface::getUsageLimit怎麽用?PHP PromotionInterface::getUsageLimit使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Sylius\Component\Promotion\Model\PromotionInterface
的用法示例。
在下文中一共展示了PromotionInterface::getUsageLimit方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: isEligible
/**
* {@inheritdoc}
*/
public function isEligible(PromotionInterface $promotion)
{
if (null === ($usageLimit = $promotion->getUsageLimit())) {
return true;
}
if ($promotion->getUsed() < $usageLimit) {
return true;
}
return false;
}
示例2:
function it_recognizes_subject_as_eligible_if_coupon_code_match($dispatcher, PromotionCouponsAwareSubjectInterface $subject, PromotionInterface $promotion, CouponInterface $coupon)
{
$subject->getPromotionCoupons()->willReturn(array($coupon));
$promotion->getStartsAt()->willReturn(null);
$promotion->getEndsAt()->willReturn(null);
$promotion->getUsageLimit()->willReturn(null);
$promotion->hasRules()->willReturn(false);
$promotion->isCouponBased()->willReturn(true);
$coupon->getPromotion()->willReturn($promotion);
$dispatcher->dispatch(SyliusPromotionEvents::COUPON_ELIGIBLE, Argument::any())->shouldBeCalled();
$this->isEligible($subject, $promotion)->shouldReturn(true);
}
示例3: isEligibleToUsageLimit
/**
* Checks if promotion usage limit has been reached.
*
* @param PromotionInterface $promotion
*
* @return bool
*/
protected function isEligibleToUsageLimit(PromotionInterface $promotion)
{
if (null !== ($usageLimit = $promotion->getUsageLimit())) {
if ($promotion->getUsed() >= $usageLimit) {
return false;
}
}
return true;
}
示例4:
function it_returns_false_if_usage_limit_has_been_exceeded(PromotionSubjectInterface $promotionSubject, PromotionInterface $promotion)
{
$promotion->getUsageLimit()->willReturn(10);
$promotion->getUsed()->willReturn(15);
$this->isEligible($promotionSubject, $promotion)->shouldReturn(false);
}