Created
March 9, 2018 16:28
-
-
Save woogists/7327d81dde3370b9c87e13848b70d094 to your computer and use it in GitHub Desktop.
[Checkout Field Editor] Setting a default value for a radio button field
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' ); |
For anyone else that finds themselves here with the same issue. I found that the WooCommerce Checkout Field Editor plugin set a priority of 1000 for their add_filter. So in order to customize things in additional (which is actually order) change the snippet to this which worked for me:
function custom_override_checkout_fields ( $fields ) {
$fields['order']['email_optin']['default'] = 'Yes';
return $fields;
} // End custom_override_checkout_fields()
add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' , 1100 );
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Same for me, can't get it to work with Additional Fields.