function _uc_quote_assemble_quotes in Ubercart 5
Same name and namespace in other branches
- 6.2 shipping/uc_quote/uc_quote.pages.inc \_uc_quote_assemble_quotes()
1 call to _uc_quote_assemble_quotes()
- uc_quote_request_quotes in shipping/
uc_quote/ uc_quote.module - Callback to return the shipping quote(s) of the appropriate quoting method(s).
File
- shipping/
uc_quote/ uc_quote.module, line 1437 - The controller module for fulfillment modules that process physical goods.
Code
function _uc_quote_assemble_quotes($order) {
global $user;
$account = user_load(array(
'uid' => $order->uid,
));
if (!$account) {
$account = $user;
}
$products = $order->products;
$shipping_types = array();
foreach ($products as $product) {
$shipping_types[] = uc_product_get_shipping_type($product);
}
$shipping_types = array_unique($shipping_types);
$all_types = module_invoke_all('shipping_type');
$shipping_type = '';
// Use the most prominent shipping type (lightest weight).
$type_weight = 1000;
// arbitrary large number
foreach ($shipping_types as $type) {
if ($all_types[$type]['weight'] < $type_weight) {
$shipping_type = $all_types[$type]['id'];
$type_weight = $all_types[$type]['weight'];
}
}
$methods = array_filter(module_invoke_all('shipping_method'), '_uc_quote_method_enabled');
uasort($methods, '_uc_quote_type_sort');
foreach ($methods as $id => $method) {
if ($method['quote']['type'] != 'order' && $method['quote']['type'] != $shipping_type) {
unset($methods[$id]);
}
}
ob_start();
//drupal_set_message('<pre>'. print_r($products, true) .'</pre>');
$quote_data = array();
foreach ($methods as $method) {
workflow_ng_invoke_event('get_quote_from_' . $method['id'], $order, $method, $account);
$data = ob_get_contents();
if ($data = unserialize($data)) {
$quote_data[$method['id']] = $data;
}
ob_clean();
}
ob_end_clean();
return $quote_data;
}