hook_cart_item() calls op 'remove' for two fairly different things:

- the user removes an item from their cart
- the user checks out their cart (and the cart is emptied by uc_cart_complete_sale().)

This on the surface makes sense, but if a 3rd party module wants to maintain its own data about products, it makes that very awkward, as it's impossible to tell from within hook_cart_item() what is happening.

I would suggest the latter case be op 'checkout' rather than 'remove'.

Comments

joachim’s picture

Status: Active » Needs review
StatusFileSize
new3.25 KB

Here's a patch.

This seemed the best approach short of writing a whole new cart emptying function for when checkout takes place.

I've filled in missing docs at the same time as adding them for the new parameter and op I am introducing.

As far as I can tell, no modules in the Ubercart package do anything on op 'remove', so no changes are needed anywhere other than uc_cart.module.

ldweeks’s picture

Any chance this will be committed to ubercart? I've run right up against this problem (ie, I want to store extra info about products), and now I'm stuck.

Thanks...

ldweeks’s picture

I actually got off my duff and applied the patch and tested it. It worked great for me. The fact that you left the 'remove' option working the way one would expect means, I think, that very few people will be affected adversely by this patch.

I like it!

ldweeks’s picture

Status: Needs review » Reviewed & tested by the community

Marking this as tested. I've been using it for a week now with no problems.

Island Usurper’s picture

Status: Reviewed & tested by the community » Fixed

Thanks for the patch and the review. Committed.

longwave’s picture

Status: Fixed » Patch (to be ported)

Needs porting to 7.x.

Island Usurper’s picture

Version: 6.x-2.x-dev » 7.x-3.x-dev
Status: Patch (to be ported) » Needs review
StatusFileSize
new2.82 KB

And it's ported.

longwave’s picture

Status: Needs review » Fixed

Committed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.