[2.5] Prevent shortcode errors when non product ID is provided

Fixes #10534
This commit is contained in:
Mike Jolley 2016-03-11 12:53:50 +00:00
parent 86a0fff731
commit 73fdfe595a
1 changed files with 5 additions and 9 deletions

View File

@ -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 '';
}