Closed (fixed)
Project:
Commerce Core
Version:
7.x-1.x-dev
Component:
Checkout
Priority:
Normal
Category:
Bug report
Assigned:
Issue tags:
Reporter:
Created:
10 Feb 2011 at 14:12 UTC
Updated:
3 Jan 2014 at 02:58 UTC
Jump to comment: Most recent
Comments
Comment #1
pcambraPull request on https://github.com/pcambra/drupalcommerce/commit/de339c232d58587933670bc...
I've noticed that commerce_cart_order_product_line_item_delete gets the line_item_id and then does a wrapper so this would mean wrapping twice for the deletion, what do you think of replacing line_item_id as parameter for the wrapper itself?
The only other function affected is this one: commerce_cart_order_empty, which, by the way doesn't seem to be invoked anywhere
Comment #2
pcambraComment #3
rszrama commentedThis won't work because it supposes that field will always be used to remove an item from the shopping cart. Instead, what needs to happen is the field's submit handler should just have a generic "Line item deleted." message when a remove button is clicked, but it should happen in its own submit handler so it can be overridden by the cart form to use a submit handler with a cart specific message.
You can see an example of this with the save button for the form. The submit array for the button specifies a separate submit handler found in commerce_line_item.module that displays the save message:
The cart module alters the button's value and its #submit array to use a different submit handler for the message:
When you give this another shot, just go ahead and wipe your branch and start over so I don't have to pull in this commit with the final solution.
Comment #4
pcambraCode moved to a submit function, same way that the update cart button does:
https://github.com/pcambra/drupalcommerce/commit/4d63e8fb1d73a48e9117e77...
Comment #5
rszrama commentedNot quite there yet... you're getting the idea, but you're still referencing a "cart" from the line item module. The message in the default submit handler should just be "Line item deleted.", and the Cart module can alter the #submit array to use a different message submit handler about removing the item from the cart.
The first code block in my comment above was from the Line Item module, but the second one was from the Cart module.
Comment #6
rszrama commentedComment #7
pcambraAnother version, this one with a default message in line_items module and the cart module overriding it
https://github.com/pcambra/drupalcommerce/commit/c332714020a509245d1a635...
Comment #8
rszrama commentedCool. Looking much closer - I don't understand why you put the wrapper into the $form_state, though. : ?
Comment #9
pcambraI think that at the point that the submit gets called, the line item has been already deleted, so is not possible to load the line item in the submit callback, we could also put only the title in the form state and move the conditions to the _form_alter instead to the submit.
Comment #10
rszrama commentedOooh, good point. Didn't think of that. ; )
Maybe we just want to store the title or something then? Or, actually, if we store the line item itself, it can still be wrapped on submit. The wrapper doesn't depend on any data coming from the database.
Comment #11
pcambraMoved the wrapper to the submit
https://github.com/rszrama/drupalcommerce/pull/62
Comment #12
recidive commentedI've tested it and it works.
Comment #13
rszrama commentedThanks for the patch and review. Committed.