Tags/topics: 
3
Answers
Vote up!
0
Vote down!

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??

Asked by: dianikol
on June 15, 2012

3 Answers

Vote up!
2
Vote down!

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,
  );
}
Andy Giles
Answer by: Andy Giles
Posted: Jun 15, 2012
Vote up!
0
Vote down!

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?

Answer by: dianikol
Posted: Jun 15, 2012
Vote up!
0
Vote down!

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!!

Answer by: alduxvm
Posted: Aug 23, 2012

Comments

You could also use your custom theme's theme.php file to implement hooks.

Josh

- Josh Miller on October 2, 2012