woocommerce_product_class filter-hookWC 3.0.0

Filter the product class name.

Usage

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

/**
 * Function for `woocommerce_product_class` filter-hook.
 * 
 * @param string $classname    Classname.
 * @param string $product_type Product type.
 * @param string $context      Context.
 * @param int    $product_id   Product ID.
 *
 * @return string
 */
function wp_kama_woocommerce_product_class_filter( $classname, $product_type, $context, $product_id ){

	// filter...
	return $classname;
}
$classname(string)
Classname.
$product_type(string)
Product type.
$context(string)
Context.
$product_id(int)
Product ID.

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 73
$classname = apply_filters( 'woocommerce_product_class', self::get_classname_from_product_type( $product_type ), $product_type, ProductType::VARIATION === $product_type ? 'product_variation' : 'product', $product_id );

Where the hook is used in WooCommerce

Usage not found.