function uc_weightquote_quote in Ubercart 5
Same name and namespace in other branches
- 6.2 shipping/uc_weightquote/uc_weightquote.module \uc_weightquote_quote()
- 7.3 shipping/uc_weightquote/uc_weightquote.module \uc_weightquote_quote()
Standard callback to return a shipping rate via the weightquote method.
Parameters
$products: The order's products.
$details: Other order details including a shipping address.
Return value
A JSON object containing the shipping quote for the order.
1 string reference to 'uc_weightquote_quote'
- uc_weightquote_shipping_method in shipping/
uc_weightquote/ uc_weightquote.module - Implementation of Übercart's hook_shipping_method().
File
- shipping/
uc_weightquote/ uc_weightquote.module, line 347 - Shipping quote module that defines a shipping rate for each product based on weight.
Code
function uc_weightquote_quote($products, $details, $method) {
$method = explode('_', $method['id']);
$mid = $method[1];
if ($method = db_fetch_object(db_query("SELECT * FROM {uc_weightquote_methods} WHERE mid = %d", $mid))) {
$rate = $method->base_rate;
foreach ($products as $product) {
$product_weight = $product->weight * uc_weight_conversion($product->weight_units, variable_get('uc_weight_unit', 'lb'));
if (is_null($product->weightquote)) {
$rate += $method->unit_rate * $product->qty * $product_weight;
}
else {
$rate += $product->weightquote[$mid] * $product->qty * $product_weight;
}
}
$quotes[] = array(
'rate' => $rate,
'format' => uc_currency_format($rate),
'option_label' => check_plain($method->label),
);
}
return $quotes;
}