hook_alloc_get_customer_names

Definition

hook_alloc_get_customer_names(&$txn, $atype = 'billing')
ecommerce-5--4/docs/developer/hooks/ec_receipt.php, line 281

Description

The allocation object provider customer names from an allocation object. Eg. store returns the customers from the transaction object.

Related topics

Namesort iconDescription
HooksAllow modules to interact with the Drupal core.

Code

<?php
function hook_alloc_get_customer_names(&$txn, $atype = 'billing') {
  if ($address = $txn->address[$atype]) {
    $names = array();
    if (!empty($address->firstname) or !empty($address->lastname)) {
      $names['fname'] = $address->firstname;
      $names['lname'] = $address->lastname;
    }
    elseif (!empty($address['firstname']) or !empty($address['lastname'])) {
      $names['fname'] = $address['firstname'];
      $names['lname'] = $address['lastname'];
    }
    else {
      $names = ec_common_split_name($address->fullname);
    }
    return !empty($names) ? $names : NULL;
  }
}
?>