Merge pull request #20213 from rnaby/240518-230624-wc-template-functions-wc_setup_product_data

wc_setup_product_data refactored
This commit is contained in:
Mike Jolley 2018-05-25 11:22:23 +01:00 committed by GitHub
commit 3cf7bfc328
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 5 deletions

View File

@ -129,16 +129,14 @@ function wc_setup_product_data( $post ) {
unset( $GLOBALS['product'] );
if ( is_int( $post ) ) {
$the_post = get_post( $post );
} else {
$the_post = $post;
$post = get_post( $post );
}
if ( empty( $the_post->post_type ) || ! in_array( $the_post->post_type, array( 'product', 'product_variation' ), true ) ) {
if ( empty( $post->post_type ) || ! in_array( $post->post_type, array( 'product', 'product_variation' ), true ) ) {
return;
}
$GLOBALS['product'] = wc_get_product( $the_post );
$GLOBALS['product'] = wc_get_product( $post );
return $GLOBALS['product'];
}