[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 '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( is_object( $product_data ) ) {
|
$product = is_object( $product_data ) && in_array( $product_data->post_type, array( 'product', 'product_variation' ) ) ? wc_setup_product_data( $product_data ) : false;
|
||||||
$product = wc_setup_product_data( $product_data );
|
|
||||||
} else {
|
if ( ! $product ) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -495,13 +495,9 @@ class WC_Shortcodes {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( is_object( $product_data ) ) {
|
$product = is_object( $product_data ) && in_array( $product_data->post_type, array( 'product', 'product_variation' ) ) ? wc_setup_product_data( $product_data ) : false;
|
||||||
$product = wc_setup_product_data( $product_data );
|
|
||||||
} else {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( 'product' !== $product_data->post_type ) {
|
if ( ! $product ) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue