function uc_ups_nodeapi in Ubercart 6.2
Same name and namespace in other branches
- 5 shipping/uc_ups/uc_ups.module \uc_ups_nodeapi()
Implements hook_nodeapi().
File
- shipping/
uc_ups/ uc_ups.module, line 156 - Shipping quote module that interfaces with www.ups.com to get rates for small package shipments.
Code
function uc_ups_nodeapi(&$node, $op) {
if (uc_product_is_product($node->type)) {
switch ($op) {
case 'insert':
case 'update':
if (isset($node->ups)) {
$ups_values = $node->ups;
if (!$node->revision) {
db_query("DELETE FROM {uc_ups_products} WHERE vid = %d", $node->vid);
}
db_query("INSERT INTO {uc_ups_products} (vid, nid, pkg_type) VALUES (%d, %d, '%s')", $node->vid, $node->nid, $ups_values['pkg_type']);
}
break;
case 'load':
if (uc_product_get_shipping_type($node) == 'small_package') {
return array(
'ups' => db_fetch_array(db_query("SELECT * FROM {uc_ups_products} WHERE vid = %d", $node->vid)),
);
}
break;
case 'delete':
db_query("DELETE FROM {uc_ups_products} WHERE nid = %d", $node->nid);
break;
case 'delete revision':
db_query("DELETE FROM {uc_ups_products} WHERE vid = %d", $node->vid);
break;
}
}
}