I am writing a Commerce submodule that needs to run some code on the line items in an order when the Update Cart or Checkout buttons are clicked in the shopping cart form, but I'm not sure where to put it. More specifically, I need to see if the user updated the quantity of a line item in their cart and then write code that acts on the quantity change (without using Rules).
I am already using hook_form_FORM_ID_alter()
to alter the Remove buttons in the shopping cart, I figured I could just add a submit handler in this hook but that doesn't seem to work.
function MYMODULE_form_views_form_commerce_cart_form_default_alter(&$form, &$form_state) {
$form['#submit'][] = 'MYMODULE_cart_submit';
}
function MYMODULE_cart_submit($form, &$form_state) {
dsm($form);
}
When I hit either Update Cart or Checkout, dsm doesn't load on the next page. Am I in the right spot?
Thanks! :)