• Resolved cmht

    (@eightsages)


    Hi,

    We’d like to have the billing email field on the checkout page default to the customer’s WordPress account email address.

    This is to minimise duplication and confusion for our customers, who typically prefer to have only a single email address in use with each account.

    How do we do this please ?

    Thanks

Viewing 7 replies - 1 through 7 (of 7 total)
  • Mohit Mishra

    (@mohitmishra)

    hello
    @eightsages
    you can try with following code, it will help you.
    add_filter( ‘woocommerce_checkout_fields’, ‘set_default_billing_address’ );

    public function set_default_billing_address ( $fields) {
    $user = wp_get_current_user();
    if ( $user ) {
    $fields[‘billing’][‘billing_email’][‘autocomplete’] = $user->data->user_email;
    }
    return $fields;
    }

    Thread Starter cmht

    (@eightsages)

    Thank you !

    If I wish to then hide the checkout page billing email address field completely (so Woocommerce uses the email from the user account), could you let me know how to do this please ?

    Much appreciated ??

    Chris

    • This reply was modified 5 years ago by cmht.
    • This reply was modified 5 years ago by cmht.
    Mohit Mishra

    (@mohitmishra)

    Hello @eightsages This code will remove the email field from the checkout

    /**
    * This function is used for remove email field from the checkout
    * 
    * @name custom_checkout_fields
    * @param array $address_fields  array of the address fields
    */
    function custom_checkout_fields( $address_fields ) {
    	unset( $address_fields['billing']['billing_email'] );
    	return $address_fields;
    }
    add_filter( 'woocommerce_checkout_fields', 'custom_checkout_fields' ,20, 1 );
    Thread Starter cmht

    (@eightsages)

    Wonderful – this is exactly what I needed.

    Thank you so much !

    Chris

    (I found that removing the email field from checkout alone is enough. Woocommerce seems to automatically then use the account email instead.)

    Thread Starter cmht

    (@eightsages)

    Sorry one last question !

    How do I hide the email address field in My Account -> Addresses -> Billing Address ?

    That way the Account Details email address will be the sole instance.

    Thanks again ??

    Mohit Mishra

    (@mohitmishra)

    Hello @eightsages For this create a new ticket and mark this ticket as resolved.
    Thanks

    Thread Starter cmht

    (@eightsages)

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘WordPress account email vs Woocommerce Billing email’ is closed to new replies.