function template_preprocess_uc_order in Ubercart 6.2
Same name and namespace in other branches
- 7.3 uc_order/uc_order.module \template_preprocess_uc_order()
Preprocess a formatted invoice with an order's data.
File
- uc_order/
uc_order.module, line 1624
Code
function template_preprocess_uc_order(&$variables) {
$variables['thank_you_message'] = FALSE;
switch ($variables['op']) {
case 'checkout-mail':
$variables['thank_you_message'] = TRUE;
case 'admin-mail':
$variables['help_text'] = TRUE;
$variables['email_text'] = TRUE;
$variables['store_footer'] = TRUE;
case 'view':
case 'print':
$variables['business_header'] = TRUE;
$variables['shipping_method'] = TRUE;
break;
}
$variables['products'] = $variables['order']->products;
if (!is_array($variables['products'])) {
$variables['products'] = array();
}
$variables['line_items'] = $variables['order']->line_items;
$items = _line_item_list();
foreach ($items as $item) {
if (isset($item['display_only']) && $item['display_only'] == TRUE) {
$result = $item['callback']('display', $variables['order']);
if (is_array($result)) {
foreach ($result as $line) {
$variables['line_items'][] = array(
'line_item_id' => $line['id'],
'title' => $line['title'],
'amount' => $line['amount'],
'weight' => $item['weight'],
'data' => isset($item['data']) ? $item['data'] : array(),
);
}
}
}
}
if (!is_array($variables['line_items'])) {
$variables['line_items'] = array();
}
usort($variables['line_items'], 'uc_weight_sort');
// Generate tokens to use as template variables.
$types = array(
'order' => $variables['order'],
);
$full = new stdClass();
$full->tokens = $full->values = array();
foreach ($types as $type => $object) {
$temp = token_get_values($type, $object, FALSE);
$full->tokens = array_merge($full->tokens, $temp->tokens);
$full->values = array_merge($full->values, $temp->values);
}
foreach ($full->tokens as $key => $token) {
$value = $full->values[$key];
$variables[str_replace('-', '_', $token)] = $value;
}
// Add template file suggestions, default to customer template.
$variables['template_files'] = array(
'uc_order-customer',
'uc_order-' . $variables['template'],
);
}