You are here

function commerce_avatax_email_to_username in Drupal Commerce Connector for AvaTax 7.5

Same name and namespace in other branches
  1. 7.3 commerce_avatax.module \commerce_avatax_email_to_username()
  2. 7.4 commerce_avatax.module \commerce_avatax_email_to_username()

Generate AvaTax user name as approximation of e-mail address.

1 call to commerce_avatax_email_to_username()
_commerce_avatax_transaction_get_customer_code in includes/commerce_avatax.calc.inc
Helper function used to determine the customerCode sent.

File

./commerce_avatax.module, line 665
AvaTax service integration from Avalara, Inc.

Code

function commerce_avatax_email_to_username($user_email) {

  // Default to the first part of the e-mail address.
  $name = substr($user_email, 0, strpos($user_email, '@'));

  // Remove possible illegal characters.
  $name = preg_replace('/[^A-Za-z0-9_.-]/', '', $name);

  // Trim that value for spaces and length.
  $name = trim(substr($name, 0, USERNAME_MAX_LENGTH - 4));
  return $name;
}