function uc_quote_action_get_quote in Ubercart 7.3
Same name and namespace in other branches
- 5 shipping/uc_quote/uc_quote.module \uc_quote_action_get_quote()
- 6.2 shipping/uc_quote/uc_quote.module \uc_quote_action_get_quote()
Retrieves shipping quote.
Parameters
$order: The order the quote is for.
$method: The shipping method to generate the quote.
Return value
Array of shipping quotes.
1 call to uc_quote_action_get_quote()
- uc_quote_assemble_quotes in shipping/
uc_quote/ uc_quote.pages.inc - Pulls the get_quote_from_* triggers and assembles their returned data.
File
- shipping/
uc_quote/ uc_quote.pages.inc, line 77 - Menu callbacks for shipping quotes requested through AJAX.
Code
function uc_quote_action_get_quote($order, $method) {
$details = array();
foreach ($order as $key => $value) {
if (substr($key, 0, 9) == 'delivery_') {
$field = substr($key, 9);
$details[$field] = $value;
}
}
ob_start();
// Load include file containing quote callback, if there is one.
if (isset($method['quote']['file'])) {
$inc_file = drupal_get_path('module', $method['module']) . '/' . $method['quote']['file'];
if (is_file($inc_file)) {
require_once $inc_file;
}
}
if (function_exists($method['quote']['callback'])) {
// This feels wrong, but it's the only way I can ensure that shipping
// methods won't mess up the products in their methods.
$products = array();
foreach ($order->products as $key => $item) {
if (uc_order_product_is_shippable($item)) {
$products[$key] = clone $item;
}
}
$quote_data = call_user_func($method['quote']['callback'], $products, $details, $method);
}
$messages = ob_get_contents();
ob_end_clean();
if ($messages && variable_get('uc_quote_log_errors', FALSE)) {
watchdog('quote', '!messages', array(
'!messages' => $messages,
), WATCHDOG_WARNING);
watchdog('quote', '<pre>@data</pre>', array(
'@data' => print_r($quote_data, TRUE),
), WATCHDOG_WARNING);
}
return $quote_data;
}