-
Notifications
You must be signed in to change notification settings - Fork 9.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect Customer TAX Class saved with Quote when VAT Validation used on Guest orders #30018
Comments
Hi @gwharton. Thank you for your report.
Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:
For more details, please, review the Magento Contributor Assistant documentation. Please, add a comment to assign the issue:
🕙 You can find the schedule on the Magento Community Calendar page. 📞 The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, please join the Community Contributions Triage session to discuss the appropriate ticket. 🎥 You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel ✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel |
Hi @engcom-Oscar. Thank you for working on this issue.
|
Hi @gwharton , thank you for your report. I have checked this issue and it reproducing even without MSI modules, on vanila 2.4-develop branch of Magento. This why I have removed MSI from description, then we could proceed to work with it on our repository. |
✅ Confirmed by @engcom-Oscar Issue Available: @engcom-Oscar, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself. |
Well, it took me about 7 hours to get to the bottom of this one. Magento\Sales\Observer\Frontend\RestoreCustomerGroupId is fired by the event sales_quote_address_collect_totals_after This is called numerous times throughout the checkout process. It looks as if this plugin checks if the setting for "Tax Calculation Based On" is set to "Shipping Address", and if the Customer Group Id of the quote has previously changed (indicating that the group has changed due to VAT validation) then the change in Group ID is reverted. I have no idea why, but this seems intentional. VAT should be calculated based on where the goods are being delivered to, not the billing address, so it seems odd to kill the updated Group ID, and hence the Customer Tax Class ID in this case. If the Group ID is not set correctly, then the quote->getCustomerTaxClassId function will not work, as it generates the tax class in real time from the group ID. This needs some thought. |
Also needs addressing if you want to keep the adjusted customer group in the quote object and order object after VAT validation for guest orders. |
The issue has been fixed by Magento team and delivered with internal PR in the scope of |
@sdzhepa, This doesn't fix the problem for me. Problem 1 The "sales_customer_validate_vat_number" event is fired on the frontend, and also webapi when VAT validation is carried out. The following observer subscribes to that event. "Magento\Sales\Observer\Frontend\RestoreCustomerGroupId" That Observer removes any changes to the quote->CustomerGroupId field which were made by the VAT Validation routines. I guess this event is not triggered by the unit test as the VAT validation object is mocked, and never fires this event. With these events in place, when the order is placed, the Observer resets the customer group in the quote to 0, which is then copied forwards into the $order object. Problem 2 The fix put in place magento2/app/code/Magento/Quote/Model/QuoteManagement.php Lines 400 to 401 in 544296e
If it is a guest order, then doesn't $quote->getCustomer() return an empty customer object magento2/app/code/Magento/Quote/Model/Quote.php Lines 1014 to 1029 in 544296e
and would just result in the fix setting the $quote->setCustomerGroupId() call with null parameter. My Workaround Stop the overwriting of the CustomerGroupId in the quote object on VAT validation. I have no idea why this is put in, in the first place. Seems incorrect for it to be there. etc/frontend/events.xml
Stop the overwriting of the CustomerGroupId in the quote object on order placement
|
status? |
Preconditions (*)
Steps to reproduce (*)
Expected result (*)
Actual result (*)
Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.
The text was updated successfully, but these errors were encountered: