woocommerce_product_class filter-hookWC 3.0.0

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

Usage

add_filter( 'woocommerce_product_class', 'wp_kama_woocommerce_product_class_filter', 10, 3 );

/**
 * Function for `woocommerce_product_class` filter-hook.
 * 
 * @param        $product_id        
 * @param string $product_type      Product type.
 * @param        $product_variation 
 *
 * @return 
 */
function wp_kama_woocommerce_product_class_filter( $product_id, $product_type, $product_variation ){

	// filter...
	return $product_id;
}
$product_id
-
$product_type(string)
Product type.
$product_variation
-

Changelog

Since 3.0.0 Introduced.

Where the hook is called

WC_Product_Factory::get_product_classname()
woocommerce_product_class
woocommerce/includes/class-wc-product-factory.php 61
$classname = apply_filters( 'woocommerce_product_class', self::get_classname_from_product_type( $product_type ), $product_type, 'variation' === $product_type ? 'product_variation' : 'product', $product_id );

Where the hook is used in WooCommerce

Usage not found.