Merge pull request #24682 from mpjason/master

Update downloadable/virtual case in wc_update_product_lookup_tables_column( $column )
This commit is contained in:
Gerhard Potgieter 2019-09-27 13:26:20 +02:00 committed by GitHub
commit a8fed61dcc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 8 deletions

View File

@ -1452,15 +1452,18 @@ function wc_update_product_lookup_tables_column( $column ) {
case 'downloadable':
case 'virtual':
$column = esc_sql( $column );
$meta_key = '_' . $column;
$wpdb->query(
"
UPDATE
{$wpdb->wc_product_meta_lookup} lookup_table
LEFT JOIN {$wpdb->postmeta} meta1 ON lookup_table.product_id = meta1.post_id AND meta1.meta_key = '_virtual'
SET
lookup_table.`{$column}` = IF ( meta1.meta_value = 'yes', 1, 0 )
"
$wpdb->prepare(
"
UPDATE
{$wpdb->wc_product_meta_lookup} lookup_table
LEFT JOIN {$wpdb->postmeta} meta1 ON lookup_table.product_id = meta1.post_id AND meta1.meta_key = %s
SET
lookup_table.`{$column}` = IF ( meta1.meta_value = 'yes', 1, 0 )
",
$meta_key
)
);
break;
case 'onsale':