WordPress WooCommerce 变体下拉 Html 覆盖 [英] WordPress WooCommerce Variation Dropdown Html Override
本文介绍了WordPress WooCommerce 变体下拉 Html 覆盖的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
基本上,我想将我的变体下拉列表转换成一些花哨的东西,例如,将其设为单选按钮.
Basically, I want to convert my variation dropdown into something fancy, like for example, make it a radio button.
但是这个过滤器不起作用.作为示例,我是这样使用它的.
But this filter is not working. As a sample, I'm using it like this.
add_filter( 'woocommerce_dropdown_variation_attribute_options_html', 'override_color_variation_display', 10, 2 );
public function override_color_variation_display( $html, $args ) {
$html = 'Some override';
return $html;
}
这是让它工作的正确方法吗?因为它没有在产品展示的任何地方显示某些覆盖"文本.
Is this the correct way to get this working? Because it's not showing the "Some override" text anywhere on the product display.
推荐答案
不确定您使用的是哪个 WooCommerce 版本,但在 2.5.1 中,此过滤器仅接受一个变量.试试这个代码:
Not sure which WooCommerce version are you using but in 2.5.1 this filter accepts only one variable. Try this code:
add_filter( 'woocommerce_dropdown_variation_attribute_options_html', 'override_color_variation_display');
function override_color_variation_display( $html ) {
$html = 'Some override';
return $html;
}
这篇关于WordPress WooCommerce 变体下拉 Html 覆盖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文