function uc_quote_request_quotes in Ubercart 5
Same name and namespace in other branches
- 6.2 shipping/uc_quote/uc_quote.pages.inc \uc_quote_request_quotes()
Callback to return the shipping quote(s) of the appropriate quoting method(s).
1 string reference to 'uc_quote_request_quotes'
- uc_quote_menu in shipping/
uc_quote/ uc_quote.module - Implementation of hook_menu().
File
- shipping/
uc_quote/ uc_quote.module, line 1372 - The controller module for fulfillment modules that process physical goods.
Code
function uc_quote_request_quotes() {
/* print '<pre>';
print_r($_POST);
print '</pre>'; */
$products = array();
foreach (explode('|', urldecode($_POST['products'])) as $item) {
$props = explode('^', $item);
$product = new stdClass();
$product->nid = $props[0];
$product->title = $props[1];
$product->model = $props[2];
$product->manufacturer = $props[3];
$product->qty = $props[4];
$product->cost = $props[5];
$product->price = $props[6];
$product->weight = $props[7];
if ($data = unserialize($props[8])) {
$product->data = $data;
}
else {
$product->data = $props[8];
}
if ($product->nid) {
$node = (array) node_load($product->nid);
foreach ($node as $key => $value) {
if (!isset($product->{$key})) {
$product->{$key} = $value;
}
}
}
$products[] = $product;
}
$fake_order = new stdClass();
$fake_order->uid = $_POST['uid'];
$fake_order->products = $products;
foreach ((array) $_POST['details'] as $type => $address) {
foreach ($address as $key => $value) {
if ($key == 'country' and $value == '') {
$value = variable_get('uc_store_country', 840);
}
$field = $type . '_' . $key;
$fake_order->{$field} = $value;
}
}
// Consider the total to be from products only, because line items are
// mostly non-existent at this point.
$fake_order->order_total = uc_order_get_total($fake_order, true);
// Get all quote types neccessary to fulfill order.
$quote_data = _uc_quote_assemble_quotes($fake_order);
//drupal_set_message('<pre>'. print_r($methods, true) .'</pre>');
//drupal_set_message('<pre>'. print_r($quote_data, true) .'</pre>');
$return_quotes = array();
foreach ($quote_data as $method_id => $options) {
foreach ($options as $accsrl => $data) {
$return_quotes[$method_id . '---' . $accsrl] = $data;
}
}
drupal_set_header("Content-Type: text/javascript; charset=utf-8");
print drupal_to_js($return_quotes);
exit;
}