Today I'd like to provide a short snippet (hook) to add an additional "Update cart" button on top of the cart view in commerce.module.
/**
* Implements hook_form_FORM-ID_alter.
* @param type $form
* @param type $form_state
*/
function MY-MODULE_form_views_form_commerce_cart_form_default_alter(&$form, &$form_state) {
// Add an update cart button before the table to make updating the amount easier.
$form['update_cart'] = array(
'#type' => 'markup',
'#markup' => '
',
'#weight' => -50,
);
}
?>
This is very helpful to make it easier to update the amount of line items in the cart if the cart page is quite long.
Please leave a comment, if this was helpful for you :)