admin管理员组文章数量:1130349
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.
Share Improve this question asked Oct 30, 2018 at 10:37 agahiagahi 1013 silver badges12 bronze badges1 Answer
Reset to default 2When 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.
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.
Share Improve this question asked Oct 30, 2018 at 10:37 agahiagahi 1013 silver badges12 bronze badges1 Answer
Reset to default 2When 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.
本文标签: woocommerce offtopicAccessing parameters when adding filter
版权声明:本文标题:woocommerce offtopic - Accessing parameters when adding filter 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749221144a2334972.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论