1

I found out that when I enter a "Full name" in the commerce shipping and billing address information, the [user:name] value will be changed to the "Full name" entered.

As you can see the user name in the first picture is different from the value of the [user:name] token.

enter image description here

enter image description here

However, when I enter a different "Full name" for subsequent orders, or change the username it doesn't modify the value of the [user:name] token.

Is there a way to stop the commerce shipping and billing to modify the [user:name] token or to change the value of the token manually?

Thank you for your help.

2 Answers 2

0

I modified the user.tokens.inc file by changing $user['name'] to $user['login-name'] and commented out a line and this seemed to fix the problem of the tokens, as the token isn't modified by the username value in $account.

case 'login-name':
//$name = format_username($account);
$replacements[$original] = $sanitize ? check_plain($name) : $name;
break;

enter image description here

However, as you can see, I still haven't solved the problem of the the username field in $account is being modified by commerce shipping and billing. The result is the same whether I set the field to "Full name" or "First name" and "Last name". Inspecting the addressfield module, I can't find the part where it modifies the $account username.

0

I've got the answer!

Go to profiles\commerce_kickstart\modules\commerce_kickstart\commerce_kickstart_user and comment out

function commerce_kickstart_user_username_alter(&$name, $account) {
  if (module_exists('commerce_addressbook')) {
    $billing_profile_id = commerce_addressbook_get_default_profile_id($account->uid, 'billing');
    if ($billing_profile_id) {
      $billing_profile = commerce_customer_profile_load($billing_profile_id);
      $name = $billing_profile->commerce_customer_address[LANGUAGE_NONE][0]['name_line'];
    }
  }
}

and everything goes back to normal!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.