function uc_ups_node_load in Ubercart 7.3
Same name and namespace in other branches
- 8.4 shipping/uc_ups/uc_ups.module \uc_ups_node_load()
Implements hook_node_load().
File
- shipping/
uc_ups/ uc_ups.module, line 175 - UPS shipping quote module.
Code
function uc_ups_node_load($nodes, $types) {
$product_types = array_intersect(uc_product_types(), $types);
if (empty($product_types)) {
return;
}
$vids = array();
$shipping_type = variable_get('uc_store_shipping_type', 'small_package');
$shipping_types = db_query("SELECT id, shipping_type FROM {uc_quote_shipping_types} WHERE id_type = :type AND id IN (:ids)", array(
':type' => 'product',
':ids' => array_keys($nodes),
))
->fetchAllKeyed();
foreach ($nodes as $nid => $node) {
if (!in_array($node->type, $product_types)) {
continue;
}
if (isset($shipping_types[$nid])) {
$node->shipping_type = $shipping_types[$nid];
}
else {
$node->shipping_type = $shipping_type;
}
if ($node->shipping_type == 'small_package') {
$vids[$nid] = $node->vid;
}
}
if ($vids) {
$result = db_query("SELECT * FROM {uc_ups_products} WHERE vid IN (:vids)", array(
':vids' => $vids,
), array(
'fetch' => PDO::FETCH_ASSOC,
));
foreach ($result as $ups) {
$nodes[$ups['nid']]->ups = $ups;
}
}
}