Merge pull request #10022 from WPprodigy/shortcode-fix

Check for a valid product ID/SKU in the add_to_cart shortcodes
This commit is contained in:
Mike Jolley 2016-01-07 10:38:18 +00:00
commit 3b6de6051a
1 changed files with 9 additions and 3 deletions

View File

@ -446,9 +446,9 @@ class WC_Shortcodes {
return ''; return '';
} }
if ( is_object( $product_data ) ) {
$product = wc_setup_product_data( $product_data ); $product = wc_setup_product_data( $product_data );
} else {
if ( ! $product ) {
return ''; return '';
} }
@ -494,6 +494,12 @@ class WC_Shortcodes {
return ''; return '';
} }
if ( is_object( $product_data ) ) {
$product = wc_setup_product_data( $product_data );
} else {
return '';
}
if ( 'product' !== $product_data->post_type ) { if ( 'product' !== $product_data->post_type ) {
return ''; return '';
} }