WC_Product_Factory::get_product_classname( int $product_id, string $product_type )

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


Description Description


Parameters Parameters

$product_id

(Required) Product ID.

$product_type

(Required) Product type.


Top ↑

Return Return

(string)


Top ↑

Source Source

File: includes/class-wc-product-factory.php

	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;
	}

Top ↑

Changelog Changelog

Changelog
Version Description
3.0.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

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