Skip to content
Advertisement

Reorder customer details in WooCommerce email notifications

I am trying to change the order of the customer details fields displayed in the Woocommerce mail sent to both customer and admin after purchase (table name: addresses).

I checked the file responsible of outputting the billing & shipping fields which is plugins/woocommerce/templates/email-customer-details.php but the customer details are outputted only through a foreach loop and the variable $fields is not even there.

JavaScript

So, where to change the order of the fields? In particular, I’d like to display the state before the zipcode.

Advertisement

Answer

There is an available filter hook for that.

It’s included in WC_Emails customer_details() method, which is used to call the template email-customer-details.php on all related main email templates.

You can use it this way (where $fields is the array of fields that you want to sort):

JavaScript

For usage, see those related on StackOverFlow

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