/** * {@inheritdoc} */ public function isEligible(PromotionSubjectInterface $subject, array $configuration) { if (!$subject instanceof OrderInterface) { throw new UnsupportedTypeException($subject, OrderInterface::class); } if (null === ($address = $subject->getShippingAddress())) { return false; } return $this->isTargetCountry($subject, $configuration['country']); }
/** * {@inheritdoc} */ public function isEligible(PromotionSubjectInterface $subject, array $configuration) { if (!$subject instanceof OrderInterface) { throw new UnsupportedTypeException($subject, 'Sylius\\Component\\Core\\Model\\OrderInterface'); } if (null === ($address = $subject->getShippingAddress())) { return false; } return $address->getCountry()->getId() === $configuration['country']; }
/** * {@inheritdoc} */ public function isEligible(PromotionSubjectInterface $subject, array $configuration) { if (!$subject instanceof OrderInterface) { throw new UnsupportedTypeException($subject, OrderInterface::class); } if (null === ($address = $subject->getShippingAddress())) { return false; } $country = $this->countryRepository->findOneBy(array('code' => $address->getCountry())); if (!$country instanceof CountryInterface) { return false; } return $country->getId() === $configuration['country']; }