Framework / CMS
WooCommerce [Version: Since 2.2.0]
Returns a WooCommerce product object using either the product object or product ID.
- product (mixed) (Required): You may use the product object or the product ID to get the product.
Return Value(s)Returns the WooCommerce product object.
This function should only be called after ‘init’ action is finished, as there might be taxonomies that are getting registered during the init action.
Examples of wc_get_product()
<?php $product_id = 1234; $product = wc_get_product($product_id);
The above returns an object of the WooCommerce product.