Update button in shopping cart block
Hi there! Is it possible to add a quantity text field and a update button into cart block like it is in the cart summary??
Hi there! Is it possible to add a quantity text field and a update button into cart block like it is in the cart summary??
dianikol,
I would do this by updating the shopping cart block view and replacing the "(Line Item) Commerce Line Item: Quantity" field with the "(Line Item) Commerce Line Item: Quantity text field (Quantity text field) " field. Then you'll need to hook_form_alter() the cart block form to add a submit/update button.
/**
* Implements hook_form_FORM_ID_alter().
*/
function your_module_name_form_views_form_commerce_cart_block_default_alter(&$form, &$form_state, $form_id) {
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Update cart'),
'#weight' => 51,
);
}
Thanks, It works great! Just a question. Why just adding is enough? I mean without having write the submit callback to update the quantities. Is it a commerce of the scenes operation or somthing?
Just a quick question??
how do i do the "Then you'll need to hook_form_alter() the cart block form to add a submit/update button" part??
I'm a little bit lost, i need to create a module just to implement that hook??
sorry if it sounds noob, but its my first time using hooks...
thanks!
cheers!!
Comments
You could also use your custom theme's theme.php file to implement hooks.
Josh