allowedCountryReader = $allowedCountryReader; $this->validationResultFactory = $validationResultFactory; $this->generalMessage = $generalMessage; } /** * @inheritdoc */ public function validate(Quote $quote): array { $validationErrors = []; if (!$quote->isVirtual()) { $shippingAddress = $quote->getShippingAddress(); $shippingAddress->setStoreId($quote->getStoreId()); $validationResult = in_array( $shippingAddress->getCountryId(), $this->allowedCountryReader->getAllowedCountries( ScopeInterface::SCOPE_STORE, $quote->getStoreId() ) ); if (!$validationResult) { $validationErrors = [__($this->generalMessage)]; } } return [$this->validationResultFactory->create(['errors' => $validationErrors])]; } }