Orders created after WooCommerce 3.0 have some special meta values that make searching faster and more accurate. Orders created before WooCommerce 3.0 don’t have these yet.
In WooCommerce 3.2, there is going to be a tool for generating the correct information for orders that don’t have the information yet (https://github.com/woocommerce/woocommerce/pull/15854).
In the meantime you can run this query in MYSQL to generate the correct information for old orders:
INSERT INTO wp_postmeta( post_id, meta_key, meta_value )
SELECT post_id, ‘_billing_address_index’, GROUP_CONCAT( meta_value SEPARATOR ‘ ‘ )
FROM wp_postmeta
WHERE meta_key IN ( ‘_billing_first_name’, ‘_billing_last_name’ )
AND post_id IN ( SELECT DISTINCT post_id FROM wp_postmeta
WHERE post_id NOT IN ( SELECT post_id FROM wp_postmeta WHERE meta_key=’_billing_address_index’ )
AND post_id IN ( SELECT post_id FROM wp_postmeta WHERE meta_key=’_billing_last_name’ ) )
GROUP BY post_id;
EDIT: The single quotes look weird on this forum. Just use regular single quotes.
Hi,
I used this SQL command, it did update a lot of rows, but searches of adresses created before 3.1 still does not work