wc_get_product()
14th January 2021
0 Comments
Framework / CMS
WooCommerce [Version: Since 2.2.0]
Syntax
Typical Usage
Returns a WooCommerce product object using either the product object or product ID.
Accepted Parameters
- 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.Notes
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()
Example 1
<?php
$product_id = 1234;
$product = wc_get_product($product_id);
The above returns an object of the WooCommerce product.
Used In Projects
Was This Helpful?
If this post has helped you, please let me know. Your feedback will be highly appreciated and will help me build better content.