How can I alter an "Add to cart" button at the submission time? I am using the Drupal Commerce module, and I need to fire some operation at the time the users click on the Add to cart button, but I am unable to find any hook for this.

I am using this code but it is not working.

/**
 * Implements hook_form_alter().
 */
function mymodule_form_alter(&amp;$form, &amp;$form_state, $form_id) {
  if($form_id == 'commerce_cart_add_to_cart_form') {
    $form['#submit'][] = 'custom_submit';
  }
}

function custom_submit($form,$form_state) {
  die("Tesing");
  drupal_set_message(t("Don't panic!"), 'warning'); 
}
You can use the form alter as follows:

function hook_form_alter(&amp;$form, &amp;$form_state, $form_id) { //hook can be replaced by theme name if being defined in *template.php* of a theme and by the module name if function is being defined inside a custom module

  if($form_id == 'commerce_cart_add_to_cart_form') {

//HERE YOU CAN DEFINE A SUBMIT HANDLER, WHICH WILL ACT ON HITTING ADD TO CART BUTTON. Example:

    $form['#submit'][] = 'custom_submit';
  }


function custom_submit($form, &amp;$form_state) { //custom submit handler

  //Add here the functionality you want to do on click of add to cart button

}