diff --git a/includes/class-wc-install.php b/includes/class-wc-install.php index 9dbf9785605..54cc0c98fc7 100644 --- a/includes/class-wc-install.php +++ b/includes/class-wc-install.php @@ -81,6 +81,7 @@ class WC_Install { ), '3.1.0' => array( 'wc_update_310_downloadable_products', + 'wc_update_310_old_comments', 'wc_update_310_db_version', ), ); diff --git a/includes/wc-update-functions.php b/includes/wc-update-functions.php index 3131fd2659f..9d11f07ba98 100644 --- a/includes/wc-update-functions.php +++ b/includes/wc-update-functions.php @@ -1112,6 +1112,15 @@ function wc_update_310_downloadable_products() { } } +/** + * Find old order notes and ensure they have the correct type for exclusion. + */ +function wc_update_310_old_comments() { + global $wpdb; + + $wpdb->query( "UPDATE $wpdb->comments comments LEFT JOIN $wpdb->posts as posts ON comments.comment_post_ID = posts.ID SET comment_type = 'order_note' WHERE posts.post_type = 'shop_order' AND comment_type = '';" ); +} + /** * Update DB Version. */