WC_Product_Factory::get_product_classname()public staticWC 3.0.0

Gets a product classname and allows filtering. Returns WC_Product_Simple if the class does not exist.

Method of the class: WC_Product_Factory{}

Hooks from the method

Return

String.

Usage

$result = WC_Product_Factory::get_product_classname( $product_id, $product_type );
$product_id(int) (required)
Product ID.
$product_type(string) (required)
Product type.

Changelog

Since 3.0.0 Introduced.

WC_Product_Factory::get_product_classname() code WC 8.6.1

public static function get_product_classname( $product_id, $product_type ) {
	$classname = apply_filters( 'woocommerce_product_class', self::get_classname_from_product_type( $product_type ), $product_type, 'variation' === $product_type ? 'product_variation' : 'product', $product_id );

	if ( ! $classname || ! class_exists( $classname ) ) {
		$classname = 'WC_Product_Simple';
	}

	return $classname;
}