woocommerce_product_class
Gets a product classname and allows filtering. Returns WC_Product_Simple if the class does not exist.
Использование
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(строка)
- Product type.
- $product_variation
- -
Список изменений
С версии 3.0.0 | Введена. |
Где вызывается хук
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 );