15 1 0 4000 1 https://codeblock.co.za 300 true 0

wc_get_product()

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.

Was This Helpful?

Previous Post
add_product()
Next Post
is_type()

0 Comments

Leave a Reply