/** * {@inheritdoc} */ public function execute(PromotionSubjectInterface $subject, array $configuration, PromotionInterface $promotion) { if (!$subject instanceof OrderInterface) { throw new UnexpectedTypeException($subject, 'Sylius\\Component\\Core\\Model\\OrderInterface'); } $adjustment = $this->createAdjustment($promotion); $adjustment->setAmount(-$subject->getAdjustmentsTotal(AdjustmentInterface::SHIPPING_ADJUSTMENT) * $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); } 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; }