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:
parent
5a9b13295a
commit
6ea6687144
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue