79 private $customerSession;
103 $this->_customerVat = $customerVat;
105 $this->_coreRegistry = $coreRegistry;
106 $this->_groupManagement = $groupManagement;
111 $this->customerSession = $customerSession;
127 if (!$this->_customerAddress->isVatValidationEnabled(
$customer->getStore())
128 || $this->_coreRegistry->registry(self::VIV_PROCESSED_FLAG)
135 $this->_coreRegistry->register(self::VIV_PROCESSED_FLAG,
true);
147 $result = $this->_customerVat->checkVatNumber(
152 $newGroupId = $this->_customerVat->getCustomerGroupIdBasedOnVatNumber(
158 if (!
$customer->getDisableAutoGroupChange() &&
$customer->getGroupId() != $newGroupId) {
161 $this->customerSession->setCustomerGroupId($newGroupId);
176 }
catch (\Exception $e) {
177 $this->_coreRegistry->register(self::VIV_PROCESSED_FLAG,
false,
true);
198 $configAddressType = $this->_customerAddress->getTaxCalculationAddressType();
229 ||
$address->getIsDefaultShipping();
242 (string)
__(
'Your VAT ID was successfully validated.'),
246 if (!$this->scopeConfig->isSetFlag(HelperAddress::XML_PATH_VIV_DISABLE_AUTO_ASSIGN_DEFAULT)
247 && !
$customer->getDisableAutoGroupChange()
249 $customerVatClass = $this->_customerVat->getCustomerVatClass(
254 ? (string)
__(
'You will be charged tax.')
255 : (string)
__(
'You will not be charged tax.');
258 $this->messageManager->addSuccess(implode(
' ',
$message));
273 (string)
__(
'The VAT ID entered (%1) is not a valid VAT ID.', $vatId),
277 if (!$this->scopeConfig->isSetFlag(HelperAddress::XML_PATH_VIV_DISABLE_AUTO_ASSIGN_DEFAULT)
278 && !
$customer->getDisableAutoGroupChange()
280 $message[] = (string)
__(
'You will be charged tax.');
283 $this->messageManager->addError(implode(
' ',
$message));
297 (string)
__(
'Your Tax ID cannot be validated.'),
301 if (!$this->scopeConfig->isSetFlag(HelperAddress::XML_PATH_VIV_DISABLE_AUTO_ASSIGN_DEFAULT)
302 && !
$customer->getDisableAutoGroupChange()
304 $message[] = (string)
__(
'You will be charged tax.');
307 $email = $this->scopeConfig->getValue(
'trans_email/ident_support/email', ScopeInterface::SCOPE_STORE);
308 $message[] = (string)
__(
'If you believe this is an error, please contact us at %1',
$email);
310 $this->messageManager->addError(implode(
' ',
$message));
elseif(isset( $params[ 'redirect_parent']))
__construct(Vat $customerVat, HelperAddress $customerAddress, Registry $coreRegistry, GroupManagementInterface $groupManagement, ScopeConfigInterface $scopeConfig, ManagerInterface $messageManager, Escaper $escaper, AppState $appState, CustomerSession $customerSession)
addInvalidMessage($customerAddress)
addValidMessage($customerAddress, $validationResult)
_canProcessAddress($address)
addErrorMessage($customerAddress)
_isDefaultBilling($address)
_isDefaultShipping($address)
execute(Observer $observer)
const VIV_CURRENTLY_SAVED_ADDRESS