[2.5] Prevent shortcode errors when non product ID is provided
Fixes #10534
This commit is contained in:
parent
86a0fff731
commit
73fdfe595a
|
@ -447,9 +447,9 @@ class WC_Shortcodes {
|
|||
return '';
|
||||
}
|
||||
|
||||
if ( is_object( $product_data ) ) {
|
||||
$product = wc_setup_product_data( $product_data );
|
||||
} else {
|
||||
$product = is_object( $product_data ) && in_array( $product_data->post_type, array( 'product', 'product_variation' ) ) ? wc_setup_product_data( $product_data ) : false;
|
||||
|
||||
if ( ! $product ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
|
@ -495,13 +495,9 @@ class WC_Shortcodes {
|
|||
return '';
|
||||
}
|
||||
|
||||
if ( is_object( $product_data ) ) {
|
||||
$product = wc_setup_product_data( $product_data );
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
$product = is_object( $product_data ) && in_array( $product_data->post_type, array( 'product', 'product_variation' ) ) ? wc_setup_product_data( $product_data ) : false;
|
||||
|
||||
if ( 'product' !== $product_data->post_type ) {
|
||||
if ( ! $product ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue