You are here

function commerce_avatax_email_to_username in Drupal Commerce Connector for AvaTax 7.3

Same name and namespace in other branches
  1. 7.5 commerce_avatax.module \commerce_avatax_email_to_username()
  2. 7.4 commerce_avatax.module \commerce_avatax_email_to_username()
1 call to commerce_avatax_email_to_username()
commerce_avatax_retrieve_sales_tax in ./commerce_avatax.module
AvaTax service: returns the sales tax amount as an array.

File

./commerce_avatax.module, line 605
Calculate Sales Tax using AvaTax Calc service 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;
}