You are here

function commerce_email_customer_name in Commerce Email 7

Get the customers name from the Customer profile using the billing or shipping address. Defaults to customer email

Parameters

$order: The order object

$customer_profile: Customer profile object

Return value

$order The order object with updated Customer name

1 call to commerce_email_customer_name()
commerce_email_order_email_send in ./commerce_email.rules.inc
Rules action: Send the users order as an HTML email

File

./commerce_email.module, line 579
Defines additional menu item and order html email functonality.

Code

function commerce_email_customer_name(&$order, $customer_profile) {
  if (!empty($customer_profile->commerce_customer_address)) {
    $order->customer_name = !empty($customer_profile->commerce_customer_address[LANGUAGE_NONE][0]['first_name']) && !empty($customer_profile->commerce_customer_address[LANGUAGE_NONE][0]['last_name']) ? $customer_profile->commerce_customer_address[LANGUAGE_NONE][0]['first_name'] . ' ' . $customer_profile->commerce_customer_address[LANGUAGE_NONE][0]['last_name'] : $customer_profile->commerce_customer_address[LANGUAGE_NONE][0]['name_line'];
  }
  else {
    $order->customer_name = $order->mail;
  }
}