Update function to ensure notes have correct type (pre WC 1.6)

This commit is contained in:
Mike Jolley 2017-06-08 12:18:07 +01:00
parent 75480ab99f
commit caacd65085
2 changed files with 10 additions and 0 deletions

View File

@ -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',
),
);

View File

@ -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.
*/