wc_get_product() – Main function for returning products, uses the WC_Product_Factory class.
You appear to be a bot. Output may be restricted
Description
Main function for returning products, uses the WC_Product_Factory class.
This function should only be called after 'init' action is finished, as there might be taxonomies that are getting registered during the init action.
Usage
$WC_Product|null|false = wc_get_product( $the_product, $deprecated );
Parameters
- $the_product
- ( mixed ) optional – Post object or post ID of the product.
- $deprecated
- ( array ) optional – Previously used to pass arguments to the factory, e.g. to force a type.
Returns
WC_Product|null|false
Source
File name: woocommerce/includes/wc-product-functions.php
Lines:
1 to 11 of 11
function wc_get_product( $the_product = false, $deprecated = array() ) { if ( ! did_action( 'woocommerce_init' ) || ! did_action( 'woocommerce_after_register_taxonomy' ) || ! did_action( 'woocommerce_after_register_post_type' ) ) { /* translators: 1: wc_get_product 2: woocommerce_init 3: woocommerce_after_register_taxonomy 4: woocommerce_after_register_post_type */ wc_doing_it_wrong( __FUNCTION__, sprintf( __( '%1$s should not be called before the %2$s, %3$s and %4$s actions have finished.', 'woocommerce' ), 'wc_get_product', 'woocommerce_init', 'woocommerce_after_register_taxonomy', 'woocommerce_after_register_post_type' ), '3.9' ); return false; } if ( ! empty( $deprecated ) ) { wc_deprecated_argument( 'args', '3.0', 'Passing args to wc_get_product is deprecated. If you need to force a type, construct the product class directly.' ); } return WC()->product_factory->get_product( $the_product, $deprecated ); }