function commerce_paypal_checkout_format_address in Commerce PayPal 7.2
Formats the given address into a format expected by PayPal.
Parameters
array $address: The address to format.
$profile_type: The profile type ("billing"|"shipping").
Return value
array The formatted address.
1 call to commerce_paypal_checkout_format_address()
- commerce_paypal_checkout_prepare_order_request in modules/
checkout/ commerce_paypal_checkout.module - Prepare the request parameters for the create/update order request.
File
- modules/
checkout/ commerce_paypal_checkout.module, line 718 - Implements PayPal Checkout in Drupal Commerce checkout.
Code
function commerce_paypal_checkout_format_address($address, $profile_type) {
$return = array();
if (!empty($address['postal_code'])) {
$return = array(
'address' => array_filter(array(
'address_line_1' => $address['thoroughfare'],
'address_line_2' => $address['premise'],
'admin_area_2' => mb_substr($address['locality'], 0, 120),
'admin_area_1' => $address['administrative_area'],
'postal_code' => mb_substr($address['postal_code'], 0, 60),
'country_code' => $address['country'],
)),
);
}
if ($profile_type == 'billing') {
$return['name'] = array(
'given_name' => $address['first_name'],
'surname' => $address['last_name'],
);
}
elseif ($profile_type == 'shipping') {
$return['name'] = array(
'full_name' => $address['name_line'],
);
}
return $return;
}