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


PHP Model\PromotionInterface类代码示例

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


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

示例1: revert

 /**
  * {@inheritdoc}
  */
 public function revert(PromotionSubjectInterface $subject, PromotionInterface $promotion)
 {
     foreach ($promotion->getActions() as $action) {
         $this->getActionCommandByType($action->getType())->revert($subject, $action->getConfiguration(), $promotion);
     }
     $subject->removePromotion($promotion);
 }
开发者ID:loic425,项目名称:Sylius,代码行数:10,代码来源:PromotionApplicator.php

示例2:

 function it_decrements_promotion_usage_if_promotion_was_used(OrderInterface $order, PromotionInterface $promotion)
 {
     $order->getPromotions()->willReturn([$promotion]);
     $promotion->getUsed()->willReturn(5);
     $promotion->setUsed(4)->shouldBeCalled();
     $this->decrementPromotionUsage($order);
 }
开发者ID:ahmadrabie,项目名称:Sylius,代码行数:7,代码来源:PromotionUsageCallbackSpec.php

示例3: getPromotionFieldsWithHeader

 /**
  * @param PromotionInterface $promotion
  * @param string $header
  *
  * @return NodeElement
  */
 private function getPromotionFieldsWithHeader(PromotionInterface $promotion, $header)
 {
     $tableAccessor = $this->getTableAccessor();
     $table = $this->getElement('table');
     $fields = $tableAccessor->getFieldFromRow($table, $tableAccessor->getRowWithFields($table, ['code' => $promotion->getCode()]), $header);
     return $fields;
 }
开发者ID:ReissClothing,项目名称:Sylius,代码行数:13,代码来源:IndexPage.php

示例4: 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

示例5: 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

示例6: createAdjustment

 /**
  * @param PromotionInterface $promotion
  * @param string $type
  *
  * @return AdjustmentInterface
  */
 protected function createAdjustment(PromotionInterface $promotion, $type = AdjustmentInterface::ORDER_PROMOTION_ADJUSTMENT)
 {
     $adjustment = $this->adjustmentFactory->createNew();
     $adjustment->setType($type);
     $adjustment->setLabel($promotion->getName());
     $this->originator->setOrigin($adjustment, $promotion);
     return $adjustment;
 }
开发者ID:ahmadrabie,项目名称:Sylius,代码行数:14,代码来源:DiscountAction.php

示例7:

 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

示例8: removeUnitOrderPromotionAdjustmentsByOrigin

 /**
  * @param OrderItemUnitInterface $unit
  * @param PromotionInterface $promotion
  */
 private function removeUnitOrderPromotionAdjustmentsByOrigin(OrderItemUnitInterface $unit, PromotionInterface $promotion)
 {
     foreach ($unit->getAdjustments(AdjustmentInterface::ORDER_PROMOTION_ADJUSTMENT) as $adjustment) {
         if ($promotion->getCode() === $adjustment->getOriginCode()) {
             $unit->removeAdjustment($adjustment);
         }
     }
 }
开发者ID:gabiudrescu,项目名称:Sylius,代码行数:12,代码来源:DiscountAction.php

示例9:

 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

示例10: createAdjustment

 /**
  * @param PromotionInterface $promotion
  *
  * @return AdjustmentInterface
  */
 protected function createAdjustment(PromotionInterface $promotion)
 {
     $adjustment = $this->adjustmentFactory->createNew();
     $adjustment->setType(AdjustmentInterface::PROMOTION_ADJUSTMENT);
     $adjustment->setDescription($promotion->getDescription());
     $this->originator->setOrigin($adjustment, $promotion);
     return $adjustment;
 }
开发者ID:aleherse,项目名称:Sylius,代码行数:13,代码来源:DiscountAction.php

示例11: createAdjustment

 /**
  * @param PromotionInterface $promotion
  * @param string $type
  *
  * @return AdjustmentInterface
  */
 protected function createAdjustment(PromotionInterface $promotion, $type = AdjustmentInterface::ORDER_SHIPPING_PROMOTION_ADJUSTMENT)
 {
     /** @var AdjustmentInterface $adjustment */
     $adjustment = $this->adjustmentFactory->createNew();
     $adjustment->setType($type);
     $adjustment->setLabel($promotion->getName());
     $adjustment->setOriginCode($promotion->getCode());
     return $adjustment;
 }
开发者ID:TheMadeleine,项目名称:Sylius,代码行数:15,代码来源:ShippingPercentageDiscountPromotionActionCommand.php

示例12: isEligible

 /**
  * {@inheritdoc}
  */
 public function isEligible(PromotionInterface $promotion)
 {
     if (null === ($usageLimit = $promotion->getUsageLimit())) {
         return true;
     }
     if ($promotion->getUsed() < $usageLimit) {
         return true;
     }
     return false;
 }
开发者ID:ahmadrabie,项目名称:Sylius,代码行数:13,代码来源:UsageLimitEligibilityChecker.php

示例13: execute

 /**
  * {@inheritdoc}
  */
 public function execute(PromotionSubjectInterface $subject, array $configuration, PromotionInterface $promotion)
 {
     if (!$subject instanceof OrderInterface && !$subject instanceof OrderItemInterface) {
         throw new UnexpectedTypeException($subject, 'Sylius\\Component\\Core\\Model\\OrderInterface or Sylius\\Component\\Core\\Model\\OrderItemInterface');
     }
     $adjustment = $this->repository->createNew();
     $adjustment->setAmount(-$configuration['amount']);
     $adjustment->setLabel(OrderInterface::PROMOTION_ADJUSTMENT);
     $adjustment->setDescription($promotion->getDescription());
     $subject->addAdjustment($adjustment);
 }
开发者ID:bcremer,项目名称:Sylius,代码行数:14,代码来源:FixedDiscountAction.php

示例14:

 function it_reverts_all_actions_registered(ServiceRegistryInterface $registry, PromotionActionCommandInterface $action, PromotionSubjectInterface $subject, PromotionInterface $promotion, PromotionActionInterface $actionModel)
 {
     $configuration = [];
     $registry->get('test_action')->willReturn($action);
     $promotion->getActions()->willReturn([$actionModel]);
     $actionModel->getType()->willReturn('test_action');
     $actionModel->getConfiguration()->willReturn($configuration);
     $action->revert($subject, $configuration, $promotion)->shouldBeCalled();
     $subject->removePromotion($promotion)->shouldBeCalled();
     $this->revert($subject, $promotion);
 }
开发者ID:TheMadeleine,项目名称:Sylius,代码行数:11,代码来源:PromotionApplicatorSpec.php

示例15: array

 function it_applies_fixed_discount_as_promotion_adjustment($adjustmentRepository, OrderInterface $order, AdjustmentInterface $adjustment, PromotionInterface $promotion)
 {
     $adjustmentRepository->createNew()->willReturn($adjustment);
     $promotion->getDescription()->willReturn('promotion description');
     $adjustment->setAmount(-500)->shouldBeCalled();
     $adjustment->setLabel(OrderInterface::PROMOTION_ADJUSTMENT)->shouldBeCalled();
     $adjustment->setDescription('promotion description')->shouldBeCalled();
     $order->addAdjustment($adjustment)->shouldBeCalled();
     $configuration = array('amount' => 500);
     $this->execute($order, $configuration, $promotion);
 }
开发者ID:bcremer,项目名称:Sylius,代码行数:11,代码来源:FixedDiscountActionSpec.php


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