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:
commit
3cf7bfc328
|
@ -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'];
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue