0

I've added some WooCommerce checkout form fields to the registration form, since my site requires customer to provide their billing address during registration.

// Custom function to display the Billing Address form to registration page
function rsc_add_billing_form_to_registration(){
    global $woocommerce;
    $checkout = $woocommerce->checkout();
    ?>
    <?php foreach ( $checkout->get_checkout_fields( 'billing' ) as $key => $field ) : ?>

        <?php if ( $key != 'billing_email' && $key != 'billing_phone' && $key != 'billing_tax_exempt_id' && $key != 'billing_verify_email' &&
        $key != 'billing_phone_ext'  ) { 
            woocommerce_form_field( $key, $field, $checkout->get_value( $key ) );
        } ?>

    <?php endforeach; 
}
add_action('woocommerce_register_form_start','rsc_add_billing_form_to_registration');

The State/ZIP fields DO change when the form is submitted but not with some kind of AJAX (I assume) call the way they do on the checkout form.

Is there a hook I need to add to have the address fields update when the customer changes their country the same way it works in checkout?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.