0

The update cart button in drupal commerce updates all quantities at once. Since on my site there will be very lengthy lists of line items in the cart, I would like to have an update cart button for each line item (see screenshot, red column). How can that be done?

enter image description here

2
  • Should the update button update all lines or only the one. (hint it will be quite hard to make it update only one).
    – googletorp
    Oct 24, 2016 at 13:53
  • unfortunately, i meant updating just only one!
    – Madam Adam
    Oct 24, 2016 at 14:43

1 Answer 1

1

This is pretty simple to explain but building this will probably give you some headaches.

  1. create a views handler (for the update button)
  2. add the button in the cart view
  3. done

Now the tricky part is building the form handler, you should take a look at commerce_line_item_handler_field_edit_delete which almost does what you need (only it deletes an item instead of saving it).

Since you only need to update the quantity you need to find out line item id and the new quantity. Load the line item and then update it. You don't need to update the order itself, commerce should handle everything when the order is updated.

1
  • Well, okay, I'll give that a try. Thank you for the clear instructions.
    – Madam Adam
    Oct 26, 2016 at 0:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.