Woocommerce rebuild sales report

We had one of our devs looking into optimizing our site as we are constantly battling slow queries. In their review they removed empty postmeta. They ran the following SQL

DELETE FROM wp_postmeta WHERE `meta_value` = '';

Report was around 180,000 records were removed. Everything seemed fine upon our review of the site and reports after this was executed.

Read More

They also added the following in our theme’s functions file.

function delete_useless_post_meta() { 
global $wpdb; 
$table = $wpdb->prefix.'postmeta'; 
$wpdb->delete ($table, array('meta_key' => '_edit_last')); 
$wpdb->delete ($table, array('meta_key' => '_edit_lock')); 
$wpdb->delete ($table, array('meta_key' => '_wp_old_slug')); } 
add_action('wp_logout','delete_useless_post_meta');

Again things seemed fine.

BUT this morning when I logged in as usual to look at overnight sales I found that our reports are reporting almost nothing and started to freak out.

So my question is: is there a way that the WooCommerce sales reports can be rebuilt?

We have an issue where our database has been written a lot since we last know the reports were good and do not know how to restore the table to restore the reports.

Related posts