Trying to add a field for Woocommerce billing_phone to the my-account/edit-account/
. It is present within the update address pages but when adding to the form-edit-account.php
it does not update.
Currently adding by following the same code as the other fields, such as first_name
:
<input type="text" class="form-control woocommerce-Input woocommerce-Input--phone input-text" name="billing_phone" id="billing_phone" value="<?php echo esc_attr( $user->billing_phone ); ?>" />
Image of form with billing_phone
being shown as a value:
But upon updating with new number it is not changed…
How can I make this being saved/updated?
You need to add a custom function hooked in
woocommerce_save_account_details
action hook:Code goes in function.php file of your active child theme (or theme) or also in any plugin file.
This code is tested on WooCommerce version 3+ and works. The data will be updated and displayed correctly.
Your complete billing phone field code in form-edit-account.php should be something like: