Skip to content

Instantly share code, notes, and snippets.

@mattyza
Created April 2, 2014 08:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattyza/d62bd33d8cb51b0e5d5b to your computer and use it in GitHub Desktop.
Save mattyza/d62bd33d8cb51b0e5d5b to your computer and use it in GitHub Desktop.
Add a default value to a radio field in the WooCommerce checkout.
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' );
@Drivingralle
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment