Skip to content

Instantly share code, notes, and snippets.

@daveloodts
Created April 21, 2021 14:38
Show Gist options
  • Save daveloodts/c5993a216746c136e2b5e8120625037b to your computer and use it in GitHub Desktop.
Save daveloodts/c5993a216746c136e2b5e8120625037b to your computer and use it in GitHub Desktop.
Volgorde van adresvelden in WooCommerce account pagina
// Account Edit Adresses: Remove and reorder addresses fields
add_filter( 'woocommerce_default_address_fields', 'custom_default_address_fields', 20, 1 );
function custom_default_address_fields( $fields ) {
if( ! is_account_page() ) return $fields;
$sorted_fields = array('first_name','last_name','country','address_1','postcode','city');
$new_fields = array();
$priority = 0;
foreach($sorted_fields as $key_field){
$priority += 10;
if( $key_field == 'postcode' )
$priority += 20; // keep space for email and phone fields
$new_fields[$key_field] = $fields[$key_field];
$new_fields[$key_field]['priority'] = $priority;
}
return $new_fields;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment