Created
April 21, 2021 14:38
-
-
Save daveloodts/c5993a216746c136e2b5e8120625037b to your computer and use it in GitHub Desktop.
Volgorde van adresvelden in WooCommerce account pagina
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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