WordPress WooCommerce Variation Dropdown Html Override

南笙酒味 提交于 2019-12-11 00:19:38

问题


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.


回答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;
}


来源:https://stackoverflow.com/questions/35053053/wordpress-woocommerce-variation-dropdown-html-override

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!