Created
October 11, 2022 13:25
-
-
Save rgpublic/1efe2832c4dd98d9c52312c2b4622385 to your computer and use it in GitHub Desktop.
Add salutation field to billing address in Drupal Commerce
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
<?php | |
function hook_commerce_inline_form_customer_profile_alter(&$inline_form,FormStateInterface $form_state,array &$complete_form) { | |
$inline_form['#after_build'][]='after_build'; | |
} | |
function after_build(&$form) { | |
$address=&$form['address']['widget'][0]['address']; | |
$address['field_salutation']=$form['field_salutation']; | |
$address['field_salutation']['#weight']=-3; | |
$address['container1']['#weight']=-2; | |
$address['organization']['#weight']=-1; | |
$address['country_code']['#weight']=1; | |
unset($form['field_salutation']); | |
return $form; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment