Magento2 – Transfer Guest Order to Customer Account Programmatically

customerguestguest-checkoutmagento2register

I've got some orders from the guest user and later they create their account and ask to link the old orders. How can I Do it?
Please Help

Best Answer

Using SQL -

UPDATE sales_order SET customer_id = {YOUR CUSTOMER ID}, customer_is_guest = 0 where entity_id = {YOUR ORDER ID};
UPDATE sales_order_grid SET customer_id = {YOUR CUSTOMER ID} where entity_id = {YOUR ORDER ID};

Using Extension -

Have a look at this solution - https://github.com/magepal/magento2-guest-to-customer

You can get some idea and customize it as per yours need.

Related Topic