magento2
magento2 copied to clipboard
Invalid address id at check out
Preconditions (*)
- Magento 2.3.2
Steps to reproduce (*)
- Delete a customer and then re-create it with the same email.
- Go to checkout with a product in the basket.
- At sending press "next".
Expected result (*)
- The next step is supposed to load
Actual result (*)
-
I get the error: Unable to save shipping information. Please check input data.
-
Error log: [2019-07-08 10:33:00] main.CRITICAL: Invalid customer-address id 6 {"exception":"[object] (Magento\Framework\Exception\NoSuchEntityException(code: 0): Invalid customer-address id 6 at /home/server/domains/dev3.domain.com/public_html/vendor/magento/module-quote/Model/QuoteAddressValidator.php:79)"} []
-
I removed the address from this customer and re-entered it. Ran the index etc. Nothing.
-
Other accounts are still ok with the checkout.
-
The table quote_address stays empty for this quote.
Hi @onepack. Thank you for your report. To help us process this issue please make sure that you provided the following information:
- [ ] Summary of the issue
- [ ] Information on your environment
- [ ] Steps to reproduce
- [ ] Expected and actual results
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:
@magento give me 2.3-develop instance
- upcoming 2.3.x release
For more details, please, review the Magento Contributor Assistant documentation.
@onepack do you confirm that you were able to reproduce the issue on vanilla Magento instance following steps to reproduce?
- [ ] yes
- [ ] no
- Join Magento Community Engineering Slack and ask your questions in #github channel.
Hi @krishprakash. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:
-
[ ] 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
Details
If the issue has a valid description, the labelIssue: Format is valid
will be added to the issue automatically. Please, edit issue description if needed, until labelIssue: Format is valid
appears. -
[ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add
Issue: Clear Description
label to the issue by yourself. -
[ ] 3. Add
Component: XXXXX
label(s) to the ticket, indicating the components it may be related to. -
[ ] 4. Verify that the issue is reproducible on
2.3-develop
branchDetails
- Add the comment@magento give me 2.3-develop instance
to deploy test instance on Magento infrastructure.
- If the issue is reproducible on2.3-develop
branch, please, add the labelReproduced on 2.3.x
.
- If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!
-
[ ] 5. Verify that the issue is reproducible on
2.2-develop
branch.Details
- Add the comment@magento give me 2.2-develop instance
to deploy test instance on Magento infrastructure.
- If the issue is reproducible on2.2-develop
branch, please add the labelReproduced on 2.2.x
-
[ ] 6. Add label
Issue: Confirmed
once verification is complete. -
[ ] 7. Make sure that automatic system confirms that report has been added to the backlog.
@magento give me 2.3-develop instance
Hi @krishprakash. Thank you for your request. I'm working on Magento 2.3-develop instance for you
Hi @krishprakash, here is your Magento instance.
Admin access: https://i-23618-2-3-develop.instances.magento-community.engineering/admin
Login: admin
Password: 123123q
Instance will be terminated in up to 3 hours.
Hi @onepack. I'm not able to reproduce this issue as provided steps by you. Please update the reproducible steps and kindly confirm that its reproducible on Vanilla Magento instance. Thanks.
Hi @krishprakash ,
I tried to reproduce the same but was not able to. The difference now is that as I remember there had been an update via an account import on this account in between. I will need to check that.
But for now, is there anyone that can explain what is happening to that account and why I get this error on it?
Please feel free to reopen the issue if you reproduce on venilla instance. Thanks
I have this issue randomly on 2.3.1
Test customer account with several saved addresses from testing the checkout, try to use one to checkout today, "Invalid customer address ID ..."
I can confirm that this is also happening at random in a commerce 2.3.2 version error: Invalid customer address id 2 {"exception":"[object] (Magento\Framework\Exception\NoSuchEntityException(code: 0): Invalid customer address id 2 at "path/to/server"/vendor/magento/module-quote/Model/QuoteAddressValidator.php:79)"} []
@magento give me 2.3-develop instance
Hi @amanuni. Thank you for your request. I'm working on Magento 2.3-develop instance for you
Hi @amanuni, here is your Magento instance.
Admin access: https://i-23618-2-3-develop.instances.magento-community.engineering/admin
Login: admin
Password: 123123q
Instance will be terminated in up to 3 hours.
It seems like this issue related to the customer id is missing.
Here is how it can be fixed locally: https://github.com/magento/magento2/issues/23908#issuecomment-515919094
The root cause is not yet clear but a solution for customers experiencing this issue is here: https://github.com/magento/magento2/issues/23908#issuecomment-518875486
I also have this issue with my test account in M 2.3.2. I don't know the root cause for it, so i added a work around for it as: in magento/vendor/magento/module-quote/Model/QuoteAddressValidator.php change the function validateForCart as from :
public function validateForCart(CartInterface $cart, AddressInterface $address): void
{
$this->doValidate($address, $cart->getCustomerIsGuest() ? null : $cart->getCustomer()->getId());
}
to:
public function validateForCart(CartInterface $cart, AddressInterface $address): void
{
$this->doValidate($address, $cart->getCustomerId() ? $cart->getCustomer()->getId() : null );
}
Please let me know its fine this change or any other patch are available for this. Thanks!
I added it below mention code at beginning of doValidate function.
if(!$customerId){
if($address->getCustomerId()){
$customerId = $address->getCustomerId();
}
}
And its seems working fine.
Steps to reproduce:
- Add products to cart
- Go to checkout
- Add email id and login from the checkout page
- After login, click the next to go to the payment page.
- Error will popup with "The shipping information was unable to be saved. Verify the input data and try again."
When we check the quote table.
SELECT entity_id, customer_id FROM quote WHERE customer_id != 0 AND customer_is_guest = 1;
+-----------+-------------+
| entity_id | customer_id |
+-----------+-------------+
| 28 | 4 |
+-----------+-------------+
The cause is that the shopping cart has customer_is_guest = 1. That causes Magento\Quote\Model'QuotaAddressValidator line 130 tot pass null to doValidate.
I suspect logging in should set customer_is_guest to 0 but doesn't or not always at least.
I don't know about you guys, but I guess I'm going to write another bugfix plugin.
@arnoutvreugdenhil I have the same problem and setting customer_is_guest to 0 fixes it. It is sporadic and seems to be related to the persistent cart.
Does anyone know how this is happening? I have some customers with that issue. No guest orders allowed - everyone need to register. So maybe theres an issue in the quote conversion after logging in? Occured in 2.3.2 - is it fixed in 2.3.3?
In my case I'm facing the same issue but that is related to an address set on quote entry that belongs to another customer.
Here a query example:
select qa.quote_id, qa.address_id as quote_address_id, cae.entity_id as customer_address_id, qa.customer_id as quote_customer_id, cae.parent_id as address_customer_id from quote_address as qa JOIN customer_address_entity as cae on (cae.entity_id=qa.customer_address_id) WHERE cae.parent_id!=qa.customer_id LIMIT 1000;
That will show the last 2 columns where is the quote_customer_id and the "address_customer_id" where is the customer related to the address entry set on address_id field on quote table.
Results in my case: +----------+------------------+---------------------+-------------------+---------------------+ | quote_id | quote_address_id | customer_address_id | quote_customer_id | address_customer_id | +----------+------------------+---------------------+-------------------+---------------------+ | 36508 | 78919 | 9789 | 9002 | 9003 | | 36508 | 78920 | 9789 | 9002 | 9003 | +----------+------------------+---------------------+-------------------+---------------------+
2 rows in set (0.72 sec)
Both customer id 9002 and 9003, in that case, one is the Admin Company user and the second is the normal company user.
I hope that helps anyone that is debugging it. I wasn't able to discover why or how that happened.
I was able to replicate this issue in 2.3.5-p1 with fresh 2.3.4 db upgrade.
One way to replicate this issue to to try:
- Disable guest checkout
- While still logged out, add an item to your cart (has this issue with downloadable product)
- Then click checkout
- On the log in screen. Log in with a customer that already has a save cart and billing info
The customer_is_guest will not get updated, which trigger the issue
Instead of PR #26637 we should consider correcting the data inconsistency which will also fix other issues by updating customer_is_guest before we submit a quote.
vendor/magento/module-quote/Model/QuoteManagement.php
Index: vendor/magento/module-quote/Model/QuoteManagement.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- vendor/magento/module-quote/Model/QuoteManagement.php (date 1589668946000)
+++ vendor/magento/module-quote/Model/QuoteManagement.php (date 1589668946000)
@@ -494,6 +494,12 @@
*/
protected function submitQuote(QuoteEntity $quote, $orderData = [])
{
+ if ($quote->getCustomer()->getId()) {
+ $quote->setCustomerIsGuest(0);
+ } else {
+ $quote->setCustomerIsGuest(1);
+ }
+
$order = $this->orderFactory->create();
$this->submitQuoteValidator->validateQuote($quote);
if (!$quote->getCustomerIsGuest()) {
2.4.2 still happening. Probably if quote was created before customer was logged in the flag does not change after the customer is logged in.
If someone faced this issue, additional workaround can be just to change is_guest flag when the customer_id is set.
update quote set customer_is_guest = 0 where customer_id > 0;
Hello,
Regarding #23908 (comment) and the customer_is_guest setting being set to 1 even though the customer is logged in, I was able to reproduce this issue, but I am not sure if this is the same for everyone.
What appears to be happening for me is that if a customer is a guest, places the order, and the order fails to be placed (for example, a hosted payment page), the quote's customer_is_guest remains set as true. If the customer then creates a new account, the quote gets assigned to that customer as expected, but the customer_is_guest setting never switches to false for some reason. After the customer creates the account, if they set a default shipping address, go to checkout, and then hit Next, the doValidate function tries to run, but since their default shipping address is assigned to the customer and their cart is marked as a "guest cart", the doValidate funtion fails on line 76 - 82:
if ($address->getCustomerAddressId()) { //Existing address cannot belong to a guest if (!$customerId) { throw new \Magento\Framework\Exception\NoSuchEntityException( __('Invalid customer address id %1', $address->getCustomerAddressId()) ); }
To fix inconsistency at checkout(after login etc. with customer_id and customer_is_guest = 1) can edit vendor/magento/module-quote/Model/Quote.php:857 (Magento 2.4.2) From:
if ($this->_customer) {
$this->setCustomerId($this->_customer->getId());
}
To:
if ($this->_customer && $this->_customer->getId()) {
$this->setCustomerId($this->_customer->getId());
$this->setCustomerIsGuest(false);
}
Of course via patch or afterBeforeSave plugin:
public function afterBeforeSave(MagentoQuote $subject, MagentoQuote $result): MagentoQuote
{
if ($result->getCustomerId()) {
$result->setCustomerIsGuest(false);
}
return $result;
}
2.4.3-p1 still happening too :(
We have same problem, version 2.4.3-p1
Magento 2.4.4
[2022-04-13T12:52:34.090875+00:00] main.CRITICAL: Magento\Framework\Exception\NoSuchEntityException: Id do endereço inválido 10781 em /var/www/html/vendor/magento/module-quote/Model/ QuoteAddressValidator.php:79
We've had the issue occur 3 times on version 2.4.3-p1. Guest checkout OFF, persistent cart OFF.