← Back to Blog

Changing the Order of Woocommerce Checkout Fields

I wanted to share this tip with you after a question I received on my YouTube channel. There is a sequence of information on the payment screen in Woocommerce. Your Name, Surname, Company Information, Country, Address. So, if you want to change this order, which hook & filter (the functions we use to intervene in […]

26 April 2021 2 dk okuma WordPress Blog

I wanted to share this tip with you after a question I received on my YouTube channel. There is a sequence of information on the payment screen in Woocommerce. Your Name, Surname, Company Information, Country, Address. So, if you want to change this order, which hook & filter (the functions we use to intervene in Woocommerce) should you use?

[toc]

The filter we need to use here is woocommerce_checkout_fields filter.

With this filter, we can rank the fields we want by changing the priority value.

Changing the Order of Woocommerce Payment Fields

For example, let’s say your customer’s email address is the most important information you want to ask, if you want to move the current email value to the top, you will need to give it a value lower than the value of the field at the top. Let’s say you want an email to be sent after your Name and Surname, you will need to look at the importance level of your Name and Surname in the table below and write a number that is greater than them but smaller than the next value. According to this example, the value the email field should receive should be between 20 and 30.

add_filter( 'woocommerce_checkout_fields', 'odeme_ekrani_siralama' );

function odeme_ekrani_siralama( $checkout_fields ) {

$checkout_fields['billing']['billing_email']['priority'] = 21;

return $checkout_fields;

}

When we run the code, since your name is 10 and your surname is 20, they will come first, followed by the email field, which will be 21.

How to Change the Order of Woocommerce Payment Fields?

You can change the location of the fields as you wish by using the table below.

Invoice Fields – Value

billing_first_name - 10

billing_last_name - 20

billing_company - 30

billing_country  - 40

billing_address_1 - 50

billing_address_2 - 60

billing_city - 70

billing_state - 80

billing_postcode - 90

billing_phone - 100

billing_email - 110

Sending Areas – Value

shipping_first_name - 10

shipping_last_name - 20

shipping_company - 30

shipping_country - 40

shipping_address_1 - 50

shipping_address_2 - 60

shipping_city - 70

shipping_state - 80

shipping_postcode - 90

Keep following my Blog for this and similar tips.

Need senior engineering ownership for your next product phase?

Share your goals and constraints, and I will return with a clear architecture direction and a practical delivery plan.