Assign or link orders to a customer account

Occasionally  you may have an instance where a customer creates an order(s) as a guest and then later decides to set up an account. You want to link those previous orders to this particular customer.

This method will also work if you want to move orders from an old customer id to a new one.

Where this probably happens very infrequently, the easiest way to do this is to go into your database tool (ie phpmyadmin) and update two tables. You’ll need to get the customer id and order id (not order number) to proceed.

You can either update manually or run these sql statements (change the YOUR_CUSTOMER_ID and YOUR_ORDER_ID to the appropriate id’s)


UPDATE sales_flat_order
SET customer_id = YOUR_CUSTOMER_ID
WHERE entity_id = YOUR_ORDER_ID AND customer_id IS NULL

UPDATE sales_flat_order_grid
SET customer_id = YOUR_CUSTOMER_ID
WHERE entity_id = YOUR_ORDER_ID AND customer_id IS NULL

Previous and/or selected orders should now appear for the selected customer when they sign in and view their orders.

Leave a Reply