how to do addition of two field values in drupal 7during node_presave? I had made two content types 
content type 1 - 'product' with field name 'product_stock' and 
content type 2 - 'Add stock' with field name 'stock_value'. It also contains a node reference to product content type.
I want to add the value of product stock and stock value during node_presave.

For Example: product stock = 10 and stock value = 14, then both should be added to give 24.
function my_module_node_presave($node){  // implementation of hook_node_presave
  if($node-&gt;type == 'add_stock') {
    $product = $node-&gt;field_stock_value['und'][0]['value']; //get data value of field
    drupal_set_message('product :'.$product); // print data value for checking
    $nid = $node-&gt;field_reference['und'][0]['nid']; //get nid of reference field
    drupal_set_message('nid :'.$nid); // print nid
    $p_node = node_load($nid); // implemenet node_load and get in $p_node
    $stock = $p_node-&gt;field_product_stock['und'][0]['value']; //get data value of field
    drupal_set_message('stock :'.$stock); // print value

    $stock = $product + $stock; // addition of both value
    drupal_set_message('Stock :'.$stock); 
    $p_node-&gt;field_product_stock['und'][0]['value'] = $stock; // updating the product field with updated value
    node_save($p_node); // implement node_save
  }
}