Updating WooCommerce Guest Orders

I am pretty sure this works…YMMV – It’s a little brutish, sorry.

Create View posts2update AS SELECT p.id, m1.meta_value AS email from ayq_posts p, ayq_postmeta m1, ayq_postmeta m2 WHERE p.ID = m1.post_id and p.ID = m2.post_id AND m1.meta_key = ‘_billing_email’ AND m1.meta_value IS NOT NULL AND m2.meta_key = ‘_customer_user’ AND m2.meta_value = 0

Create View posts2update2 AS (Select posts2update.id as postid, posts2update.email, ayq_users.ID as userid from posts2update, ayq_users where ayq_users.user_email=posts2update.email)

You can also use Create Table


UPDATE `ayq_postmeta` pm
INNER JOIN posts2update2 p2
ON pm.post_id = p2.postid
SET ayq_postmeta.`meta_value` = posts2update2.userid
pm.meta_key=’_customer_user’ AND

AND p2.email=’sometestemail’

Always test first, and back up your database.

Similar Posts