woocommerce_product_related_posts_relate_by_category
Usage
add_filter( 'woocommerce_product_related_posts_relate_by_category', 'wp_kama_woocommerce_product_related_posts_relate_by_category_filter', 10, 2 );
/**
* Function for `woocommerce_product_related_posts_relate_by_category` filter-hook.
*
* @param $true
* @param $product_id
*
* @return
*/
function wp_kama_woocommerce_product_related_posts_relate_by_category_filter( $true, $product_id ){
// filter...
return $true;
}
- $true
- -
- $product_id
- -
Where the hook is called
woocommerce_product_related_posts_relate_by_category
woocommerce/includes/wc-product-functions.php 1441
$cats_array = apply_filters( 'woocommerce_product_related_posts_relate_by_category', true, $product_id ) ? apply_filters( 'woocommerce_get_related_product_cat_terms', wc_get_product_term_ids( $product_id, 'product_cat' ), $product_id ) : array();
Where the hook is used in WooCommerce
woocommerce/src/Blocks/BlockTypes/ProductCollection/HandlerRegistry.php 119
add_filter( 'woocommerce_product_related_posts_relate_by_category', $category_callback, PHP_INT_MAX );
woocommerce/src/Blocks/BlockTypes/ProductCollection/HandlerRegistry.php 130
remove_filter( 'woocommerce_product_related_posts_relate_by_category', $category_callback, PHP_INT_MAX );