|
Apache/2.4.41 (Ubuntu) Linux vmi616275.contaboserver.net 5.4.0-84-generic #94-Ubuntu SMP Thu Aug 26 20:27:37 UTC 2021 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) server ip : 62.171.164.128 | your ip : 127.0.0.1 safemode OFF > / home / dev2.destoffenstraat.com / app / code / Swissup / Taxvat / Plugin / Action / |
Filename | /home/dev2.destoffenstraat.com/app/code/Swissup/Taxvat/Plugin/Action/MultishippingSetBilling.php |
Size | 2.5 kb |
Permission | rwxrwxrwx |
Owner | root : root |
Create time | 17-Aug-2025 10:26 |
Last modified | 13-Jan-2021 14:38 |
Last accessed | 23-Aug-2025 02:07 |
Actions | edit | rename | delete | download (gzip) |
View | text | code | image |
<?php
namespace Swissup\Taxvat\Plugin\Action;
class MultishippingSetBilling
{
/**
* @var \Swissup\Taxvat\Helper\Data
*/
private $helper;
/**
* \Magento\Framework\App\RequestInterface
*/
private $request;
/**
* \Magento\Framework\App\ResponseInterface
*/
private $response;
/**
* \Magento\Framework\Message\ManagerInterface
*/
private $messageManager;
/**
* \Magento\Framework\App\Response\RedirectInterface
*/
private $redirect;
/**
* \Magento\Customer\Api\AddressRepositoryInterface
*/
private $addressRepository;
/**
* @param \Swissup\Taxvat\Helper\Data $helper
* @param \Magento\Framework\App\RequestInterface $request
* @param \Magento\Framework\App\ResponseInterface $response
* @param \Magento\Framework\Message\ManagerInterface $messageManager
* @param \Magento\Framework\App\Response\RedirectInterface $redirect
* @param \Magento\Customer\Api\AddressRepositoryInterface $addressRepository
*/
public function __construct(
\Swissup\Taxvat\Helper\Data $helper,
\Magento\Framework\App\RequestInterface $request,
\Magento\Framework\App\ResponseInterface $response,
\Magento\Framework\Message\ManagerInterface $messageManager,
\Magento\Framework\App\Response\RedirectInterface $redirect,
\Magento\Customer\Api\AddressRepositoryInterface $addressRepository
) {
$this->helper = $helper;
$this->request = $request;
$this->response = $response;
$this->messageManager = $messageManager;
$this->redirect = $redirect;
$this->addressRepository = $addressRepository;
}
public function aroundExecute(
\Magento\Multishipping\Controller\Checkout\Address\SetBilling $subject,
callable $proceed
) {
$addressId = $this->request->getParam('id');
if (!$addressId) {
return $proceed();
}
if (!$this->helper->canValidateVat()) {
return $proceed();
}
try {
$address = $this->addressRepository->getById($addressId);
} catch (\Exception $e) {
return $proceed();
}
if ($this->helper->validateAddress($address)) {
return $proceed();
}
$this->messageManager->addErrorMessage(__('Please enter a valid VAT number.'));
$this->redirect->redirect(
$this->response,
$this->redirect->getRedirectUrl()
);
}
}
namespace Swissup\Taxvat\Plugin\Action;
class MultishippingSetBilling
{
/**
* @var \Swissup\Taxvat\Helper\Data
*/
private $helper;
/**
* \Magento\Framework\App\RequestInterface
*/
private $request;
/**
* \Magento\Framework\App\ResponseInterface
*/
private $response;
/**
* \Magento\Framework\Message\ManagerInterface
*/
private $messageManager;
/**
* \Magento\Framework\App\Response\RedirectInterface
*/
private $redirect;
/**
* \Magento\Customer\Api\AddressRepositoryInterface
*/
private $addressRepository;
/**
* @param \Swissup\Taxvat\Helper\Data $helper
* @param \Magento\Framework\App\RequestInterface $request
* @param \Magento\Framework\App\ResponseInterface $response
* @param \Magento\Framework\Message\ManagerInterface $messageManager
* @param \Magento\Framework\App\Response\RedirectInterface $redirect
* @param \Magento\Customer\Api\AddressRepositoryInterface $addressRepository
*/
public function __construct(
\Swissup\Taxvat\Helper\Data $helper,
\Magento\Framework\App\RequestInterface $request,
\Magento\Framework\App\ResponseInterface $response,
\Magento\Framework\Message\ManagerInterface $messageManager,
\Magento\Framework\App\Response\RedirectInterface $redirect,
\Magento\Customer\Api\AddressRepositoryInterface $addressRepository
) {
$this->helper = $helper;
$this->request = $request;
$this->response = $response;
$this->messageManager = $messageManager;
$this->redirect = $redirect;
$this->addressRepository = $addressRepository;
}
public function aroundExecute(
\Magento\Multishipping\Controller\Checkout\Address\SetBilling $subject,
callable $proceed
) {
$addressId = $this->request->getParam('id');
if (!$addressId) {
return $proceed();
}
if (!$this->helper->canValidateVat()) {
return $proceed();
}
try {
$address = $this->addressRepository->getById($addressId);
} catch (\Exception $e) {
return $proceed();
}
if ($this->helper->validateAddress($address)) {
return $proceed();
}
$this->messageManager->addErrorMessage(__('Please enter a valid VAT number.'));
$this->redirect->redirect(
$this->response,
$this->redirect->getRedirectUrl()
);
}
}