function uc_flatrate_quote in Ubercart 6.2
Same name and namespace in other branches
- 5 shipping/uc_flatrate/uc_flatrate.module \uc_flatrate_quote()
- 7.3 shipping/uc_flatrate/uc_flatrate.module \uc_flatrate_quote()
Standard callback to return a shipping rate via the flat rate method.
Parameters
$products: The order's products.
$details: Other order details including a shipping address.
$method: The shipping method to create the quote.
Return value
An array containing the shipping quote for the order.
1 string reference to 'uc_flatrate_quote'
- uc_flatrate_shipping_method in shipping/
uc_flatrate/ uc_flatrate.module - Implements Ubercart's hook_shipping_method().
File
- shipping/
uc_flatrate/ uc_flatrate.module, line 206 - Shipping quote module that defines a flat shipping rate for each product.
Code
function uc_flatrate_quote($products, $details, $method) {
$method = explode('_', $method['id']);
$mid = $method[1];
$context = array(
'revision' => 'altered',
'type' => 'amount',
);
if ($method = db_fetch_object(db_query("SELECT * FROM {uc_flatrate_methods} WHERE mid = %d", $mid))) {
// Start at the base rate.
$rate = uc_price($method->base_rate, $context);
foreach ($products as $product) {
if (empty($product->flatrate) || is_null($product->flatrate[$mid])) {
$price_info = array(
'price' => $method->product_rate,
'qty' => $product->qty,
);
// Add the method's default product rate.
$rate += uc_price($price_info, $context);
}
else {
$price_info = array(
'price' => $product->flatrate[$mid],
'qty' => $product->qty,
);
// Add the product-specific rate.
$rate += uc_price($price_info, $context);
}
}
$context['revision'] = 'formatted';
$formatted = uc_price($rate, $context);
$quotes[] = array(
'rate' => $rate,
'format' => $formatted,
'option_label' => check_plain($method->label),
);
}
return $quotes;
}