After the request from one of our clients, we had to give some thought to the code we put to you at the time in the post How do you add a NIF or CIF field to WooCommerce 2.1?, in order to get the customer’s telephone to be displayed, as well as the NIF/CIF in all the WooCommerce 2.1 address fields, and for it also to be compulsory. The reason? He needed it so that the transport company could get in touch with the customer.

Well then, so that you can see that it is really quite simple, first we are going to put the complete PHP code that needs to be added to the functions.php file of your child theme, and afterwards we will analyse the lines we have modified from the code published in the post How do you add a NIF or CIF field to WooCommerce 2.1?:

Copy to clipboard

In it we have made the following modifications:

  1. The campos_de_direccion function, where we have told it that the telephone field is compulsory.
  2. The anade_campo_nif_direccion_facturacion function, where we have added the telephone field to the billing address.
  3. The anade_campo_nif_direccion_envio function, where we have added the telephone field to the shipping address.
  4. The formato_direccion_de_facturacion function, where we have added the telephone field to the replacement fields in the local address format.
  5. The formato_direccion_localizacion function, where we have added the telephone field to the local, Spanish, address format.
  6. The anade_campo_nif_usuario_direccion_facturacion function, where we have added the telephone field to the address form.
  7. The anade_campo_nif_usuario_direccion_envio function, where we have added the telephone field to the shipping form.
  8. The anade_campo_nif_editar_direccion function, where we have added the telephone field to the address forms of the My account page.
  9. The anade_campo_nif_editar_direccion_pedido function, where we have added the telephone field to the address forms of Orders in the WooCommerce administration panel.
  10. The carga_hoja_de_estilo_editar_direccion_pedido function, where we edit the CSS code of the telephone field of the previous forms.

With these modifications we will have covered 100% of the needs that WooCommerce poses to us when it comes to making a field compulsory, in this case the telephone, and to displaying it in the order and on the invoice next to another field that is not “native”, such as the NIF/CIF field.

We hope that, as always, you like this post and find it useful, and we look forward to your comments.

Related posts

Comments

Suscríbete
Notificar de
0 Comments
Más antiguos
Más recientes Más votados

In this post

Products and services

Latest posts

Latest comments

Subscribe!

Lista de correos de APG

DATA PROTECTION: In accordance with data protection regulations, we provide you with the following processing information: (+)

  • Responsible: Art Project Group.
  • Treatment purposes: to respond to queries or any type of request made by the user through any of the forms of contact that are made available on the website. Sending communications about products or services (with your consent).
  • Your rights: access, rectification, portability, deletion, limitation and opposition. More information about the treatment in the Privacy Policy.

What we post on !

Se ha publicado #WooCommerce 11.2.2: actualización de seguridad que refuerza las API REST y Store, mejora la validación de CSV y corrige problemas en pagos y pedidos. Incluye cambios en la base de datos.

¡Actualiza cuanto antes!

November 5, 2026