/**
  * {@inheritdoc}
  */
 public function revert(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');
     }
     foreach ($subject->getAdjustments(AdjustmentInterface::ORDER_PROMOTION_ADJUSTMENT) as $adjustment) {
         if ($promotion->getCode() === $adjustment->getOriginCode()) {
             $subject->removeAdjustment($adjustment);
         }
     }
 }
Пример #2
0
 public function revert(PromotionSubjectInterface $subject, array $configuration, PromotionInterface $promotion)
 {
     if (!$subject instanceof OrderInterface) {
         return;
     }
     if (!$promotion instanceof OriginAwareInterface) {
         return;
     }
     /** @var AdjustmentInterface $adjustment */
     foreach ($subject->getAdjustments() as $adjustment) {
         if ($adjustment->getOriginId() === $promotion->getOriginId() && $adjustment->getOriginType() === $promotion->getOriginType() && $adjustment->getType() === $this->getAdjustmentType()) {
             $subject->removeAdjustment($adjustment);
             break;
         }
     }
 }