wc_get_product_object( string $product_type, int $product_id )

Get a product object.


Description Description

See also See also


Top ↑

Parameters Parameters

$product_type

(Required) Product type. If used an invalid type a WC_Product_Simple instance will be returned.

$product_id

(Required) Product ID.


Top ↑

Return Return

(WC_Product)


Top ↑

Source Source

File: includes/wc-product-functions.php

function wc_get_product_object( $product_type, $product_id = 0 ) {
	$classname = WC_Product_Factory::get_product_classname( $product_id, $product_type );

	return new $classname( $product_id );
}

Top ↑

Changelog Changelog

Changelog
Version Description
3.9.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.