當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。