Iam using uc_stock module functions of ubercart module in my function but not getting result as i want. here is my code:

function my_module_node_presave($node) {  
  if ($node->type == 'add_stock') {
    if (module_exists('uc_stock') && function_exists('uc_stock_adjust')) {
      $newStock = $node->field_stock_value['und'][0]['value'];
      drupal_set_message('new stock :' . $newStock);

      $sku = $node->field_sku['und'][0]['value'];
      drupal_set_message('sku :'. $sku);

      $key = $node->field_reference['und'][0]['nid'];
      drupal_set_message('key :'. $key);

      $items = field_get_items('node', $node, 'field_sku');
      drupal_set_message("<pre>" . print_r($items, true) . "</pre>"); 
      $sku = $items[0];
      drupal_set_message("<pre>" . print_r($sku, true) . "</pre>");     

      $stock_adjust = uc_stock_adjust($sku, $newStock);
      drupal_set_message('stock_adjust :'.$stock_adjust);

      $stock_set = uc_stock_set($sku, $newStock);
      drupal_set_message('stock_set :'.$stock_set);

in my code

$stock_adjust = uc_stock_adjust($sku, $newStock);

$stock_set = uc_stock_set($sku, $newStock);

the above two functions were returning no value. now anyone can tell me whats the problem in my code


Function uc_stock_adjust has no return value.

Description: This function adjust a particular product SKU by a certain value (a positive integer will add to stock, a negative integer will remove from stock).

$sku - The product SKU that will have its stock level adjusted
$qty - The quantity to add to the stock level

Return value: No return value.

  • how can use uc_stock module with my custom module. I want to use the functioning of uc_stock module in my custom module. First, this is possible? if yes. how?
    – aashi
    Jan 28 '13 at 6:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.