/** * {@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->createAdjustment($promotion); $adjustment->setAmount(-$subject->getPromotionSubjectTotal() * $configuration['percentage']); $subject->addAdjustment($adjustment); }
/** * {@inheritdoc} */ public function execute(PromotionSubjectInterface $subject, array $configuration, PromotionInterface $promotion) { if (!$subject instanceof OrderInterface) { throw new UnexpectedTypeException($subject, OrderInterface::class); } $adjustment = $this->createAdjustment($promotion); $adjustmentAmount = (int) round($subject->getPromotionSubjectTotal() * $configuration['percentage']); $adjustment->setAmount(-$adjustmentAmount); $subject->addAdjustment($adjustment); }
/** * {@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); }
/** * {@inheritdoc} */ public function execute(PromotionSubjectInterface $subject, array $configuration, PromotionInterface $promotion) { if (!$subject instanceof OrderInterface) { throw new UnexpectedTypeException($subject, OrderInterface::class); } if (!isset($configuration['percentage'])) { return false; } $adjustment = $this->createAdjustment($promotion); $adjustmentAmount = (int) round($subject->getAdjustmentsTotal(AdjustmentInterface::SHIPPING_ADJUSTMENT) * $configuration['percentage']); $adjustment->setAmount(-$adjustmentAmount); $subject->addAdjustment($adjustment); return true; }