Even though you could override the class and redefine the constant, any other references to that constant in the codebase are still going to get the original value. That's because the object manager isn't involved in the access of the constant. It's being accessed straight from the original class.
I took a look at the Magento 2.3.4 codebase, and luckily it looks like that constant is only used in the
You can't make a plugin on that method due to it being
protected, but here is what you could do to achieve what you are looking for:
Create Class Preference
<preference for="Magento\Customer\Model\Vat" type="Custom\Module\Model\CustomVat"/>
class CustomVat extends \Magento\Customer\Model\Vat
const VAT_VALIDATION_WSDL_URL = 'http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl';
protected function createVatNumberValidationSoapClient($trace = false)
return new \SoapClient(self::VAT_VALIDATION_WSDL_URL, ['trace' => $trace]);
This should do the trick, but keep in mind, this only works because you're also overriding the method that is calling
self::VAT_VALIDATION_WSDL_URL, which has the effect of using your overridden value.
Any methods you don't override in the parent
Vat class that call
self::VAT_VALIDATION_WSDL_URL will return the parent's constant value, not yours.
Also, any references to that constant that might occur from somewhere else in the code base are not going to use your value.