function uc_flatrate_quote in Ubercart 7.3
Same name and namespace in other branches
- 5 shipping/uc_flatrate/uc_flatrate.module \uc_flatrate_quote()
- 6.2 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 use to create the quote.
Return value
An array containing the shipping quote for the order.
1 string reference to 'uc_flatrate_quote'
- uc_flatrate_uc_shipping_method in shipping/
uc_flatrate/ uc_flatrate.module - Implements hook_uc_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];
if ($method = db_query("SELECT * FROM {uc_flatrate_methods} WHERE mid = :mid", array(
':mid' => $mid,
))
->fetchObject()) {
// Start at the base rate.
$rate = $method->base_rate;
foreach ($products as $product) {
if (!isset($product->flatrate[$mid])) {
// Add the method's default product rate.
$rate += $method->product_rate * $product->qty;
}
else {
// Add the product-specific rate.
$rate += $product->flatrate[$mid] * $product->qty;
}
}
$quotes[] = array(
'rate' => $rate,
'label' => check_plain($method->label),
'option_label' => check_plain($method->label),
);
}
return $quotes;
}