• mitcheljn

    (@mitcheljn)


    Hi,

    I have a code below which I am getting from the registration form, same fields are also there at the WooCommerce checkout billing address. By below code values are saving in the database at WooCommerce billing meta values, but once I get to the checkout page after logging in with the same account, nothing is reflecting there.

    All billing fields are empty except for email. So can you please help me with how can I update billing address fields with the below code and it will also show the same data in billing fields value.

    Any help will be appreciated.

    Thanks in advance.

    <?php
    $current_user = wp_get_current_user();
    $user_id = get_current_user_id();
    $dataUser = get_user_meta ( $user_id);
    $aux = get_userdata( $user_id );
    
    $businessName = $dataUser['user_registration_business_name'][0];
    $streetaddress = $dataUser['user_registration_delivery_address'][0];
    $billingCity = $dataUser['user_registration_billing_city'][0];
    $billingZip = $dataUser['user_registration_billing_postcode'][0];
    $billingCountry = $dataUser['user_registration_country_name'][0];
    $billingState = $dataUser['user_registration_billing_state'][0];
    $billingPhone = $dataUser['user_registration_billing_phone'][0];
    
    $data = array(
        'billing_city'          => $billingCity,
        'billing_postcode'      => $billingZip,
        'billing_email'         => $current_user->user_email,
        'billing_phone'         => $billingPhone,
    );
    foreach ($data as $meta_key => $meta_value ) {
        update_user_meta( $user_id, $meta_key, $meta_value );
    }
    ?>
    • This topic was modified 5 years ago by Jan Dembowski. Reason: Moved to Fixing WordPress, this is not an Developing with WordPress topic

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘WooCommerce Billing not update’ is closed to new replies.