Reputation: 609
I have customized my WooCommerce checkout in functions.php
to disable all billing address fields as my Stripe gateway does not require it.
I would like to allow customers to create an account during checkout too but it only asks for a username/password and wordpress accounts require an email. since I have disabled email in billing section the user cannot register.
I do not want the email address to stay in billing details as it will always show.
My ideal solution is having it in the account section.
How do I either
Any help is appreciated.
Upvotes: 1
Views: 383
Reputation: 29614
You can use
woocommerce_checkout_fields
hookhttps://github.com/woocommerce/woocommerce/blob/4.1.0/includes/class-wc-checkout.php#L265
- Get an array of checkout fields.
Add the following code to functions.php
// Add field
function filter_woocommerce_checkout_fields( $fields ) {
$fields['account']['billing_email'] = array(
'label' => __('E-mailadres', 'woocommerce'),
'required' => true,
'type' => 'email',
'class' => array('form-row-wide'),
'validate' => array('email'),
'autocomplete' => 'email'
);
return $fields;
}
add_filter( 'woocommerce_checkout_fields' , 'filter_woocommerce_checkout_fields', 10, 1 );
Upvotes: 1