问题
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