Created
April 2, 2014 08:36
-
-
Save mattyza/d62bd33d8cb51b0e5d5b to your computer and use it in GitHub Desktop.
Add a default value to a radio field in the WooCommerce checkout.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function custom_override_checkout_fields ( $fields ) { | |
$fields['billing']['test_radio']['default'] = 'one'; | |
return $fields; | |
} // End custom_override_checkout_fields() | |
add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I used this snippet to pre-select a radio button within the order/additional fields ($fields['order']) that I had added with the "Checkout Field Editor" plugin.
To make it work properly the filter needed to be added with an priority of at least 1001, because the "Checkout Field Editor" plugin hooks itself into with a priority of 1000.
Hope that helps outer people.