• Resolved Ben

    (@benimator)


    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)
  • Plugin Support Sravan Bhaskaravajjula

    (@bhshravankumar)

    Hello @benimator,

    What is the checkout template you are using? Have you tried creating another email field through the CartFlows form field editor? You can create additonal form fields using the custom form fieldeditor.

    Looking forward to hearing from you.

    Plugin Support Aamir

    (@aamiribsf)

    Hello?@benimator ,

    We haven’t heard from you for a while, so we will mark this thread as resolved.

    In case of any other queries, don’t hesitate to open a new thread.

    Best,

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Add Confirm Email Address Field at checkout’ is closed to new replies.