You want to change the position of the checkout fields of woocommerce but don’t know how?
You are using the woocommerce plugin to sell, when in the checkout section in the checkout there are many redundant fields or you simply do not want to display them, so today I will share how to remove the fields included in the checkout of woocommerce.
First, open the function.php file and create a function called remove_field_checkout().
then hook it to woocommerce_checkout_fields.
The code will have the following content:
<code>
add_filter<span class="br0">(</span> <span class="st_h">'woocommerce_checkout_fields'</span> <span class="sy0">,</span> <span class="st_h">'remove_field_checkout'</span> <span class="br0">)</span><span class="sy0">;</span>
<span class="kw2">function</span> remove_field_checkout<span class="br0">(</span> <span class="re0">$fields</span> <span class="br0">)</span> <span class="br0">{</span>
<span class="kw1">return</span> <span class="re0">$fields</span><span class="sy0">;</span>
<span class="br0">}
</span></code><div>
<span>1</span><span>2</span><span>3</span><span>4</span><span>5</span><span>6</span>
</div>
You just need to pass in the field that you need to remove. Below is a list of the fields currently available in checkout.
Unset unnecessary fields in checkout
<code> unset($fields['billing']['billing_first_name']); unset($fields['billing']['billing_last_name']); unset($fields['billing']['billing_company']); unset($fields['billing']['billing_address_1']); unset($fields['billing']['billing_address_2']); unset($fields['billing']['billing_city']); unset($fields['billing']['billing_postcode']); unset($fields['billing']['billing_country']); unset($fields['billing']['billing_state']); unset($fields['billing']['billing_phone']); unset($fields['order']['order_comments']); unset($fields['billing']['billing_email']); unset($fields['account']['account_username']); unset($fields['account']['account_password']); unset($fields['account']['account_password-2']); </code><div> <span>1</span><span>2</span><span>3</span><span>4</span><span>5</span><span>6</span><span>7</span><span>8</span><span>9</span><span>10</span><span>11</span><span>12</span><span>13</span><span>14</span><span>15</span><span>16</span> </div>
Move the position of fields in woocommerce checkout
To be able to do this, you can use the following code in the remove_field_checkout() function above:
<code>$fields['billing']['billing_first_name']['priority'] = 1; </code><div><span>1</span></div>
In which, [‘billing_first_name’] is the name of the field that I choose, [‘priority’] is the position (display priority).
Here priority = 1 so it will be in the top position.
Epilogue
Hopefully this tutorial is a small part of how to change the position of woocommerce checkout fields.
If you find it interesting, you can follow the woocommerce tips section to know more new knowledge, good and extremely useful tips.
Follow fanpage to receive the latest posts: Group
Wish you have interesting and interesting knowledge about wordpress!

