当前位置: 首页>>代码示例>>PHP>>正文


PHP PromotionInterface::isCouponBased方法代码示例

本文整理汇总了PHP中Sylius\Component\Promotion\Model\PromotionInterface::isCouponBased方法的典型用法代码示例。如果您正苦于以下问题:PHP PromotionInterface::isCouponBased方法的具体用法?PHP PromotionInterface::isCouponBased怎么用?PHP PromotionInterface::isCouponBased使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Sylius\Component\Promotion\Model\PromotionInterface的用法示例。


在下文中一共展示了PromotionInterface::isCouponBased方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: createForPromotion

 /**
  * {@inheritdoc}
  */
 public function createForPromotion(PromotionInterface $promotion)
 {
     Assert::true($promotion->isCouponBased(), sprintf('Promotion with name %s is not coupon based.', $promotion->getName()));
     $coupon = $this->factory->createNew();
     $coupon->setPromotion($promotion);
     return $coupon;
 }
开发者ID:ReissClothing,项目名称:Sylius,代码行数:10,代码来源:CouponFactory.php

示例2: isEligible

 /**
  * {@inheritdoc}
  */
 public function isEligible(PromotionSubjectInterface $promotionSubject, PromotionInterface $promotion)
 {
     if (!$promotion->isCouponBased()) {
         throw new UnsupportedPromotionException('Only coupon based promotions can be evaluated by this checker.');
     }
     if (!$promotionSubject instanceof OrderInterface) {
         return false;
     }
     $coupon = $promotionSubject->getPromotionCoupon();
     if (!$coupon instanceof CouponInterface) {
         return false;
     }
     if ($promotion !== $coupon->getPromotion()) {
         return false;
     }
     $couponUsageLimit = $coupon->getPerCustomerUsageLimit();
     if (0 === $couponUsageLimit) {
         return true;
     }
     $customer = $promotionSubject->getCustomer();
     if (null === $customer) {
         return false;
     }
     $placedOrdersNumber = $this->orderRepository->countByCustomerAndCoupon($customer, $coupon);
     // <= because we need to include the cart orders as well
     return $placedOrdersNumber <= $couponUsageLimit;
 }
开发者ID:ReissClothing,项目名称:Sylius,代码行数:30,代码来源:CouponsEligibilityChecker.php

示例3:

 function it_creates_a_coupon_and_assigns_a_promotion_to_id(FactoryInterface $factory, PromotionInterface $promotion, PromotionCouponInterface $coupon)
 {
     $factory->createNew()->willReturn($coupon);
     $promotion->getName()->willReturn('Christmas sale');
     $promotion->isCouponBased()->willReturn(true);
     $coupon->setPromotion($promotion)->shouldBeCalled();
     $this->createForPromotion($promotion)->shouldReturn($coupon);
 }
开发者ID:loic425,项目名称:Sylius,代码行数:8,代码来源:PromotionCouponFactorySpec.php

示例4:

 function it_returns_false_if_subject_coupons_is_not_eligible(PromotionCouponEligibilityCheckerInterface $promotionCouponEligibilityChecker, PromotionCouponAwarePromotionSubjectInterface $promotionSubject, PromotionInterface $promotion, PromotionCouponInterface $promotionCoupon)
 {
     $promotion->isCouponBased()->willReturn(true);
     $promotionSubject->getPromotionCoupon()->willReturn($promotionCoupon);
     $promotionCoupon->getPromotion()->willReturn($promotion);
     $promotionCouponEligibilityChecker->isEligible($promotionSubject, $promotionCoupon)->willReturn(false);
     $this->isEligible($promotionSubject, $promotion)->shouldReturn(false);
 }
开发者ID:loic425,项目名称:Sylius,代码行数:8,代码来源:PromotionSubjectCouponEligibilityCheckerSpec.php

示例5: isEligible

 /**
  * {@inheritdoc}
  */
 public function isEligible(PromotionSubjectInterface $promotionSubject, PromotionInterface $promotion)
 {
     if (!$promotion->isCouponBased()) {
         throw new UnsupportedPromotionException('Only coupon based promotions can be evaluated by this checker.');
     }
     if (!$promotionSubject instanceof CouponAwarePromotionSubjectInterface) {
         return false;
     }
     if (null === $promotionSubject->getPromotionCoupon()) {
         return false;
     }
     return $promotion === $promotionSubject->getPromotionCoupon()->getPromotion();
 }
开发者ID:ReissClothing,项目名称:Sylius,代码行数:16,代码来源:CouponsEligibilityChecker.php

示例6: isEligible

 /**
  * {@inheritdoc}
  */
 public function isEligible(PromotionSubjectInterface $promotionSubject, PromotionInterface $promotion)
 {
     if (!$promotion->isCouponBased()) {
         return true;
     }
     if (!$promotionSubject instanceof PromotionCouponAwarePromotionSubjectInterface) {
         return false;
     }
     $promotionCoupon = $promotionSubject->getPromotionCoupon();
     if (null === $promotionCoupon) {
         return false;
     }
     if ($promotion !== $promotionCoupon->getPromotion()) {
         return false;
     }
     return $this->promotionCouponEligibilityChecker->isEligible($promotionSubject, $promotionCoupon);
 }
开发者ID:loic425,项目名称:Sylius,代码行数:20,代码来源:PromotionSubjectCouponEligibilityChecker.php

示例7:

 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);
 }
开发者ID:gaetzone,项目名称:Sylius,代码行数:12,代码来源:PromotionEligibilityCheckerSpec.php

示例8: isEligibleToRule

 /**
  * Checks is a promotion is eligible to a subject for a given rule.
  *
  * @param PromotionSubjectInterface $subject
  * @param PromotionInterface        $promotion
  * @param RuleInterface             $rule
  *
  * @return bool
  */
 protected function isEligibleToRule(PromotionSubjectInterface $subject, PromotionInterface $promotion, RuleInterface $rule)
 {
     $checker = $this->registry->get($rule->getType());
     if ($checker->isEligible($subject, $rule->getConfiguration())) {
         return true;
     }
     if (!$promotion->isCouponBased()) {
         return false;
     }
     if ($subject instanceof PromotionCouponAwareSubjectInterface) {
         $coupon = $subject->getPromotionCoupon();
         if (null !== $coupon && $promotion === $coupon->getPromotion()) {
             $this->dispatcher->dispatch(SyliusPromotionEvents::COUPON_NOT_ELIGIBLE, new GenericEvent($promotion));
         }
     } elseif ($subject instanceof PromotionCouponsAwareSubjectInterface) {
         foreach ($subject->getPromotionCoupons() as $coupon) {
             if ($promotion === $coupon->getPromotion()) {
                 $this->dispatcher->dispatch(SyliusPromotionEvents::COUPON_NOT_ELIGIBLE, new GenericEvent($promotion));
             }
         }
     }
     return false;
 }
开发者ID:Mangetsu,项目名称:Sylius,代码行数:32,代码来源:PromotionEligibilityChecker.php

示例9: areCouponsEligibleForPromotion

 /**
  * Checks are subject's coupons eligible to promotion.
  *
  * @param PromotionSubjectInterface $subject
  * @param PromotionInterface        $promotion
  *
  * @return Boolean
  */
 private function areCouponsEligibleForPromotion(PromotionSubjectInterface $subject, PromotionInterface $promotion)
 {
     if (!$promotion->isCouponBased()) {
         return true;
     }
     $eligible = false;
     if ($subject instanceof PromotionCouponAwareSubjectInterface) {
         if (null !== ($coupon = $subject->getPromotionCoupon() && $promotion === $coupon->getPromotion())) {
             $eligible = true;
         }
     } elseif ($subject instanceof PromotionCouponsAwareSubjectInterface) {
         foreach ($subject->getPromotionCoupons() as $coupon) {
             if ($promotion === $coupon->getPromotion()) {
                 $eligible = true;
             }
         }
     } else {
         return false;
     }
     if ($eligible) {
         $this->dispatcher->dispatch(SyliusPromotionEvents::COUPON_ELIGIBLE, new GenericEvent($promotion));
     }
     return $eligible;
 }
开发者ID:wecodenlsystem,项目名称:Sylius,代码行数:32,代码来源:PromotionEligibilityChecker.php

示例10:

 function it_returns_false_if_subject_is_not_coupon_aware(PromotionSubjectInterface $subject, PromotionInterface $promotion)
 {
     $promotion->isCouponBased()->willReturn(true);
     $this->isEligible($subject, $promotion)->shouldReturn(false);
 }
开发者ID:ReissClothing,项目名称:Sylius,代码行数:5,代码来源:CouponsEligibilityCheckerSpec.php


注:本文中的Sylius\Component\Promotion\Model\PromotionInterface::isCouponBased方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。