How to sum two fields I have a content type with the field_watermelons and field_apples fields. I want to record the sum of these fields in the (existing) field_total_fruits field. How can I achieve this?

I do not want to use the Computed field module(because of PHP filter requirement) and the Math Field module is also out because it can't handle Field Collections at the moment (if it could, then I'd have my answer).

I tried hook_form_alter with a callback function attached to the $form['submit']. In that callback, I've tried a number of methods of inserting new values including adding values to $form_state's input, values, completed_form. I've also tried to use entity_metadata_wrapper() approaches in the callback, to no avail. I also tried form_set_value(). 

How to create a Rules action set to calculate a sum of integers in a Field Collection? looks interesting, but there's no answer. 

Surely I'm over-thinking this. Can someone tell me if there's a simple way to sum two field values and insert that sum into the value of another field programmatically? 

I suppose I could use the Drupal AJAX system too. I just didn't want that hassle, thinking that there's an easier way, but perhaps it's the best option.
Ok, I've got a solution that will work for me. This d.o forum comment was very helpful.

Instead of changing the $form['submit'] array, prepend the callback to the submit callback stack! Like so:

array_unshift($form['actions']['submit']['#submit'], 'MODULE_my_custom_submit_handler');

Note that the code in the comment from d.o is a bit off, you don't need to assign the unshift'ed array, you just run array_unshift on the array itself.

Once that's added in your hook_form_alter you can do WHATEVER processing magic you want with form_set_value(). Cool! Thanks all.

EDIT: here's what the callback looks like. Also note that for some reason someone took out my fields in my original question. But these field names would make more sense if someone didn't do that.

function MODULE_my_custom_submit_handler($form, &amp;$form_state) {
  $lang = $form['language']['#value'];

  $a = $form_state['values']['field_fruit_collection'][$lang][0]['field_watermelon']['und'][0]['value'];
  $b = $form_state['values']['field_fruit_collection'][$lang][0]['field_apples']['und'][0]['value'];

  $sum = $a + $b;
  form_set_value($form['field_total_fruit'][$lang][0]['value'], $sum, $form_state);
}