Call wc_setup_product_data if the global product variable is not an instance of WC_Product. (https://github.com/woocommerce/woocommerce-blocks/pull/10128)

This commit is contained in:
Patricia Hillebrandt 2023-07-07 11:40:46 +02:00 committed by GitHub
parent 5a9b13295a
commit 6ea6687144
1 changed files with 9 additions and 0 deletions

View File

@ -373,6 +373,15 @@ class BlockTemplatesController {
}
);
global $product;
if ( ! $product instanceof \WC_Product ) {
$product_id = get_the_ID();
if ( $product_id ) {
wc_setup_product_data( $product_id );
}
}
$new_content = SingleProductTemplateCompatibility::add_compatibility_layer( $template->content );
$template->content = $new_content;
}