How to Fix “Invalid address id” Error When Adding Products to Cart in Magento 2

One of the common issues Magento 2 developers and store owners may face is the
“Invalid address id” error when a logged-in customer tries to add
products to the shopping cart.
This problem usually occurs when the system gets confused due to multiple active
quotes being assigned to the same customer.

Why does this happen?

In Magento 2, each logged-in customer has an active quote
(shopping cart record) in the database.
However, in certain scenarios, the customer may end up with
more than one active quote, which leads to conflicts.

Common reasons include:

  • Multiple devices or sessions creating new quotes simultaneously.
  • Custom modules or third-party extensions that override quote creation logic.
  • Incomplete checkout sessions leaving behind active quotes that were never closed.

Step-by-Step Solution

To resolve the issue, you need to inspect the quote table in your
Magento 2 database and clean up duplicate active quotes for the affected customer.

1. Check all active quotes for the customer


SELECT entity_id, is_active
FROM quote
WHERE customer_id = <customer_id>;
  

Replace <customer_id> with the actual customer ID.
You can find this ID from your Magento Admin panel under:
Customers → All Customers.

2. Deactivate duplicate quotes

If you see more than one record where is_active = 1,
it means the customer has multiple active carts.
To deactivate them, run the following query:


DELETE FROM quote
WHERE customer_id = <customer_id> 
  AND is_active = 1;
  

⚠️ Important: This will delete all active quotes for the customer.
Make sure to confirm with the customer before proceeding,
as it will clear their shopping cart.

Best Practices

  • Check custom extensions that might be creating extra quotes.
  • Ensure your checkout flow is properly closing inactive quotes.
  • Always test in a staging environment before applying queries to production.
  • Take a database backup before making direct changes.

Conclusion

The “Invalid address id” error in Magento 2 is usually caused by
duplicate active quotes for a customer.
By cleaning up the quote table and ensuring that only one active
quote exists per customer, you can quickly resolve this issue.
Long-term, review any customizations or extensions that interfere with cart creation
to prevent the problem from recurring.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *