I am trying to change the out put of wc_get_rating_html using this filter
apply_filters( 'woocommerce_product_get_rating_html', $html, $rating, $count);
So far this function works and of course doesn't make any changes.
add_filter('woocommerce_product_get_rating_html', 'change_rating_output');
function change_rating_output($html){
return $html;
}
My question is that how I can access those $rating and $count parameters inside the function change_rating_output so that I can change the $html as I need.
I am trying to change the out put of wc_get_rating_html using this filter
apply_filters( 'woocommerce_product_get_rating_html', $html, $rating, $count);
So far this function works and of course doesn't make any changes.
add_filter('woocommerce_product_get_rating_html', 'change_rating_output');
function change_rating_output($html){
return $html;
}
My question is that how I can access those $rating and $count parameters inside the function change_rating_output so that I can change the $html as I need.
When you call add_filter()
, set the fourth parameter to 3
(which is the number of parameters accepted by the callback function which in your case is change_rating_output()
), and then change your change_rating_output()
function so that it accepts the $rating
and $count
parameters:
add_filter('woocommerce_product_get_rating_html', 'change_rating_output', 10, 3);
function change_rating_output($html, $rating, $count){
// Now do what you want with $rating and $count
return $html;
}
See http://developer.wordpress/reference/functions/add_filter/ for further details.