Skip to content
Advertisement

How to add a new field to my account details between other fields

With the snippet below we add a billing phone field to the account edit details.

This works without problems, only we would have liked to add the new field between the email and the password change section field.

enter image description here

JavaScript

Advertisement

Answer

The way you apply the code is recommended. However, because you want to add the new field in a very specific place, I would recommend the following

Step 1: overwriting the template file

https://github.com/woocommerce/woocommerce/blob/3.8.0/templates/myaccount/form-edit-account.php

  • This template can be overridden by copying it to yourtheme/woocommerce/myaccount/form-edit-account.php.

Replace: line 42 – 47

JavaScript

With

JavaScript

Step 2 & Step 3

To save and validate the field you can keep your existing code (I adjusted these slightly)

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement