Reputation: 3
I am trying to place an order without filling in the email field at the checkout form. I used this code to remove all field values (except country) :
add_filter( 'woocommerce_checkout_get_value' , 'clear_checkout_fields' , 10, 2 );
function clear_checkout_fields( $value, $input ){
if( $input != 'billing_country' )
$value = '';
return $value;
}
When placing the order without filling in the email field the order gets placed with the email of the account it is placed with. I want to be able to place an order without filling in an email address so it shows no email address on the orders page on the WooCommerce dashboard.
Any suggestions?
Upvotes: 0
Views: 1394
Reputation:
Set default value for this field to admin email.
add_filter( 'woocommerce_checkout_fields', 'woo_default_email' );
function woo_default_email($fields) {
$fields['billing']['billing_email']['default'] = get_option('admin_email');
return $fields;
}
Then just remove field from output in your template and email message.
Upvotes: 1