Add Confirm Email Address Field at checkout
-
Hello. I’d like to add an additional field to the checkout page for users to confirm their email address. I’ve noticed the email field is in woocommerce-billing-fields-custom section.
I grabbed some code from the follow website and modified it slightly. However the confirm email field still shows up in the regular woocommerce-billing-fields section.
https://www.businessbloomer.com/woocommerce-add-confirm-email-address-field-checkout/// 1) Make original email field half width // 2) Add new confirm email field add_filter( 'woocommerce_checkout_fields' , 'bbloomer_add_email_verification_field_checkout' ); function bbloomer_add_email_verification_field_checkout( $fields ) { $fields['billing']['billing_email']['class'] = array( 'form-row-first' ); $fields['billing']['billing_em_ver'] = array( 'label' => 'Confirm Email Address', 'required' => true, 'class' => array( 'form-row-last' ), 'clear' => true, 'priority' => 2, 'section' => 'woocommerce-billing-fields-custom' ); return $fields; } // --------------------------------- // 3) Generate error message if field values are different add_action( 'woocommerce_checkout_process', 'bbloomer_matching_email_addresses' ); function bbloomer_matching_email_addresses() { $email1 = $_POST['billing_email']; $email2 = $_POST['billing_em_ver']; if ( $email2 !== $email1 ) { wc_add_notice( 'Your email addresses do not match', 'error' ); } }
How do I make it show up next to the existing email field?
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Add Confirm Email Address Field at checkout’ is closed to new replies.