wc_setup_product_data()
When the_post is called, put product data into a global.
Хуков нет.
Возвращает
WC_Product.
Использование
wc_setup_product_data( $post );
- $post(разное) (обязательный)
- Post Object.
Код wc_setup_product_data() wc setup product data WC 10.3.5
function wc_setup_product_data( $post ) {
unset( $GLOBALS['product'] );
if ( is_int( $post ) ) {
$post = get_post( $post );
}
if ( empty( $post->post_type ) || ! in_array( $post->post_type, array( 'product', 'product_variation' ), true ) ) {
return;
}
$GLOBALS['product'] = wc_get_product( $post );
return $GLOBALS['product'];
}