function uc_addresses_order_pane_address in Ubercart Addresses 6.2
Same name and namespace in other branches
- 7 uc_addresses.ubercart.inc \uc_addresses_order_pane_address()
Callback for an address order pane.
Parameters
string $type: The address type: billing or shipping.
string $op: The operation that is being performed.
array/object $order: The Ubercart order.
array $values: The values from the order form.
Return value
mixed Depending on the operation, different results may be returned.
2 calls to uc_addresses_order_pane_address()
- uc_addresses_order_pane_bill_to in ./
uc_addresses.ubercart.inc - Callback for the "bill to" pane.
- uc_addresses_order_pane_ship_to in ./
uc_addresses.ubercart.inc - Callback for the "ship to" pane.
File
- ./
uc_addresses.ubercart.inc, line 265 - Ubercart callbacks for the checkout- and order panes.
Code
function uc_addresses_order_pane_address($type, $op, $order, $values = array()) {
global $user;
drupal_add_js(drupal_get_path('module', 'uc_addresses') . '/uc_addresses.js');
drupal_add_js(drupal_get_path('module', 'uc_order') . '/uc_order.js');
if ($type == 'shipping') {
$other_type = 'billing';
$uc_type = 'delivery';
}
else {
$other_type = 'delivery';
$uc_type = 'billing';
}
switch ($op) {
case 'customer':
case 'view':
drupal_add_css(drupal_get_path('module', 'uc_addresses') . '/uc_addresses.css');
$lines = array();
$values = uc_addresses_preprocess_address($order->uc_addresses[$type], 'order_view');
foreach ($values as $fieldname => $value) {
if (isset($value['title']) && $value['title'] != '') {
$lines[] = '<strong>' . $value['title'] . '</strong>: ' . $value['data'];
}
else {
$lines[] = $value['data'] . '<br />';
}
}
$output = '<br />' . implode('<br />', $lines);
return $output;
case 'edit-form':
// Initialize pane description.
switch ($type) {
case 'shipping':
$description = t("Modify 'Ship to' information");
break;
case 'billing':
$description = t("Modify 'Bill to' information");
break;
}
// Get address for order if set.
if (isset($order->uc_addresses[$type])) {
$address = $order->uc_addresses[$type];
}
$form = array(
'#type' => 'fieldset',
'#title' => $description,
'#collapsible' => TRUE,
'#collapsed' => FALSE,
);
// View the address form.
$form[$uc_type] = array(
'#type' => 'uc_addresses_address',
'#uc_addresses_context' => 'order_form',
'#key_prefix' => $uc_type,
);
if (!$address) {
$address = UcAddressesAddress::newAddress();
}
// Add address to the form.
$form[$uc_type]['#uc_addresses_address'] = $address;
return $form;
case 'edit-title':
switch ($type) {
case 'shipping':
$copy_text = t("Copy billing information.");
break;
case 'billing':
$copy_text = t("Copy shipping information.");
break;
}
$output = ' <img src="' . base_path() . drupal_get_path('module', 'uc_store') . '/images/address_book.gif" alt="' . t('Select from address book.') . '" ' . 'title="' . t('Select from address book.') . '" onclick="load_address_select(' . $order['order_uid']['#value'] . ', \'#' . $uc_type . '_address_select\', \'' . $uc_type . '\');" ' . 'style="position: relative; top: 2px; cursor: pointer;" />';
$output .= ' <img src="' . base_path() . drupal_get_path('module', 'uc_store') . '/images/copy.gif" alt="' . $copy_text . '" title="' . $copy_text . '" onclick="uc_addresses_copy_address_order(\'' . $other_type . '\', \'' . $uc_type . '\');" ' . 'style="position: relative; top: 2px; cursor: pointer;" />';
return $output;
case 'edit-theme':
$output = '<div id="' . $uc_type . '-pane"><div id="' . $uc_type . '_address_select"></div>' . drupal_render($order[$uc_type]) . '</div>';
return $output;
case 'edit-process':
$order_values = $order;
$saved_order = uc_order_load($order_values['order_id']);
$address = $saved_order->uc_addresses[$type];
$changes = array();
foreach ($order_values[$uc_type] as $key => $value) {
// Set value.
$order_values[$key] = $value;
// Check if the value was changed.
$fieldname = substr($key, strlen($uc_type) + 1);
try {
if ($address
->getField($fieldname) != $value) {
$changes[$key] = $value;
}
} catch (UcAddressesException $e) {
// Ignore any Ubercart Addresses exceptions.
}
}
return $changes;
}
}