Hi,
there's a bug on stock control, the test to check if automatic stock handling is missing, you should have (I've used a switch to be coherent with the whole module) :
<?php/**
* Implementation of hook_nodeapi().
*/
function uc_product_power_tools_nodeapi(&$node, $op) {
if($op == 'presave') {
$class_settings = db_fetch_array(db_query("SELECT * FROM {uc_power_tools} WHERE pcid = '%s'", $node->type));
if ($class_settings['pcid'] != $node->type) {
return;
}
if (
$class_settings['lp'] == 1) {
$node->list_price = $node->sell_price;
}
if (
$class_settings['asku'] == 1) {
if (module_exists('token')) {
$newsku = token_replace($class_settings['asku-settings'], 'node', $node);
$node->model = $newsku;
}
}
}
if($op == 'insert' || $op == 'update') {
// Handle Stock settings here.
if (module_exists('uc_stock')) {
$class_settings = db_fetch_array(db_query("SELECT * FROM {uc_power_tools} WHERE pcid = '%s'", $node->type));
switch ($class_settings['stock']) {
case 1:
if ($class_settings['pcid'] != $node->type) {
return;
}
$result = db_fetch_array(db_query("SELECT * FROM {uc_product_stock} WHERE sku = '%s' AND nid = %d", $node->model, $node->nid));
if ($result['sku'] != $node->model) {
db_query("INSERT INTO {uc_product_stock} (sku, nid, active, stock, threshold) VALUES ('%s', %d, 1, %d, %d)", $node->model, $node->nid, $class_settings['stock-settings'], $class_settings['stock-threshold']);
}
else {
db_query("UPDATE {uc_product_stock} SET active=1, stock=%d, threshold=%d WHERE sku = '%s' AND nid = %d", $class_settings['stock-settings'], $class_settings['stock-threshold'], $node->model, $node->nid);
}
break;
}
}
}
}
?>