How can I call a function of one module in another module? I want to call uc_stock_adjust()
function of uc_stock.module in my own custom module. Is it possible?
Here is my code so far:
function my_module_node_presave($node){
if($node->type == 'add_stock') {
$stock_value = $node->field_stock_value['und'][0]['value'];
$sku = $node->field_sku['und'][0]['value'];
if (module_exists('uc_stock') && function_exists('uc_stock_adjust')) {
uc_stock_adjust($sku, $stock_value);
}
}
}
I want to add and delete stock of products by using reference uc_stock_adjust()
, which is defined in uc_stock.module, in my custom module. But when I try the above code, it doesn't work.
It giving an error, and the error is:
Notice: Undefined variable: sku in my_module_node_presave() (line 29 of \sites\all\modules\my_module\my_module.module)