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