validate function in vatvalidation calls checkVatNumber a lot #17658
Labels
Component: Quote
Fixed in 2.3.x
The issue has been fixed in 2.3 release line
help wanted
Issue: Clear Description
Gate 2 Passed. Manual verification of the issue description passed
Issue: Confirmed
Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed
Issue: Format is valid
Gate 1 Passed. Automatic verification of issue format passed
Issue: Ready for Work
Gate 4. Acknowledged. Issue is added to backlog and ready for development
Reproduced on 2.2.x
The issue has been reproduced on latest 2.2 release
Reproduced on 2.3.x
The issue has been reproduced on latest 2.3 release
I discovered this issue because I use the following module: Dutchento_Vatfallback. In here I configured Vatlayer so vatnumbers within Magento are validated through their API. No I saw the calls to their API where extreme high, so I went debugging first in the module and after that in Magento itself. After a while I came across the
validate
function in the filemagento/module-quote/Observer/Frontend/Quote/Address/VatValidator.php
.Before calling
$this->customerVat->checkVatNumber
this function checks:I expected validated addresses would be stored in de db because of this check, but after digging around,
$quoteAddress->getValidatedCountryCode()
and$quoteAddress->getValidatedVatNumber()
are doing nothing at all, so it is expected they are quote_address attributes in the db.But in the file
magento/module-quote/Setup/InstallData.php
only the following attributes are installed:but
validated_country_code
andvalidated_vat_number
are missing and nowhere to be found.When I installed the missing attributes with a custom InstallData script everything works as expected.
Preconditions
Steps to reproduce
To reproduce this I recommend setting up vat validation with help from the docs and enable breakpoints with xdebug within the
validate
function and check how often$this->customerVat->checkVatNumber
is called.validate
is triggered by an Observer:magento/module-quote/Observer/Frontend/Quote/Address/CollectTotalsObserver.php
so it is called a lot. Try adding a product to the cart for example.Expected result
The expected result is the check inside the
validate
function:will actually do something.
Actual result
The checks are now doing nothing because the attributes in quote_address don't exist. When I install the missing attributes:
validated_country_code
andvalidated_vat_number
with a custom InstallData script everything works as expected.The text was updated successfully, but these errors were encountered: