function uc_quote_build_quote_form in Ubercart 7.3
Same name and namespace in other branches
- 8.4 shipping/uc_quote/uc_quote.module \uc_quote_build_quote_form()
Calculates and returns the shipping quote selection form.
2 calls to uc_quote_build_quote_form()
- uc_checkout_pane_quotes in shipping/
uc_quote/ uc_quote.module - Shipping quote checkout pane callback.
- uc_order_pane_quotes in shipping/
uc_quote/ uc_quote.module - Shipping quote order pane callback.
File
- shipping/
uc_quote/ uc_quote.module, line 787 - The controller module for fulfillment modules that process physical goods.
Code
function uc_quote_build_quote_form($order, $show_errors = TRUE) {
$return = array();
module_load_include('inc', 'uc_quote', 'uc_quote.pages');
$quotes = uc_quote_assemble_quotes($order);
$quote_options = array();
if (!empty($quotes)) {
foreach ($quotes as $method => $data) {
foreach ($data as $accessorial => $quote) {
$key = $method . '---' . $accessorial;
if (isset($quote['rate'])) {
$quote_options[$key] = t('!label: !price', array(
'!label' => $quote['option_label'],
'!price' => $quote['format'],
));
$return[$key]['rate'] = array(
'#type' => 'hidden',
'#value' => $quote['rate'],
);
}
if (!empty($quote['error'])) {
$return[$key]['error'] = array(
'#markup' => '<div class="quote-error">' . theme('item_list', array(
'items' => $quote['error'],
)) . '</div>',
);
}
if (!empty($quote['notes'])) {
$return[$key]['notes'] = array(
'#markup' => '<div class="quote-notes">' . $quote['notes'] . '</div>',
);
}
if (!empty($quote['debug'])) {
$return[$key]['debug'] = array(
'#markup' => '<pre>' . $quote['debug'] . '</pre>',
);
}
if (!isset($quote['rate']) && isset($quote['label']) && count($return[$key])) {
$return[$key]['#prefix'] = $quote['label'] . ': ';
}
}
}
}
$num_quotes = count($quote_options);
$default = key($quote_options);
if ($num_quotes > 1) {
if (isset($order->quote['method']) && isset($order->quote['accessorials'])) {
$chosen = $order->quote['method'] . '---' . $order->quote['accessorials'];
if (isset($quote_options[$chosen])) {
$default = $chosen;
}
}
$return['quote_option'] = array(
'#type' => 'radios',
'#options' => $quote_options,
'#default_value' => $default,
);
}
elseif ($num_quotes == 1) {
$return['quote_option'] = array(
'#type' => 'hidden',
'#value' => $default,
'#suffix' => $quote_options[$default],
);
}
elseif ($show_errors) {
$return['error'] = array(
'#markup' => filter_xss_admin(variable_get('uc_quote_err_msg', t("There were problems getting a shipping quote. Please verify the delivery address and product information and try again.\nIf this does not resolve the issue, please call @phone to complete your order.", array(
'@phone' => variable_get('uc_store_phone', NULL),
)))),
);
}
$return['#theme'] = 'uc_quote_returned_rates';
return $return;
}