Steps to reproduce:
1. Create several products (at least 2, I'd suggest 3)
2. Create a Product Kit
3. Add at least 2 (I'd suggest 3) products in your Product Kit
4. Now add this Product Kit to your cart
5. Go back to your Product Kit page & edit it
6. Remove one of the products
7. Save
At that point the cart was NOT updated. I usually get this error:
warning: Division by zero in .../sites/all/modules/ubercart/uc_product_kit/uc_product_kit.module on line 1090.
although not always. I'm not too sure what that is, but the real problem is not the division anyway...
At that point, I cannot get rid of the one product that was removed from the kit (from the UI that is.) It will stick to the cart and be invisible. That being said, it looks like I would not purchase it (i.e. the total looks correct without that item) but it is not unlikely that many other issues will ensue because of this! (i.e. If I remove the kit from my cart, I can still go to the Check Out page even though I have "nothing" in the cart and the total says $0.00. The reality is it is not exactly empty...)
I probably will not too often do something like this, but this is not a reason to not have valid code! All the people who put a kit in their cart should get their cart checked out to make sure that changes to the kit are reflected in there. I will be updating my kits all the time so they need to work right! 8-)
I may have a look later to see if I can find a fix, but I'm really not familiar with that code. If you have a good idea, let me know.
Thank you.
Alexis Wilke
| Comment | File | Size | Author |
|---|---|---|---|
| #12 | 620844-uc_product_kit-update-cart.patch | 682 bytes | longwave |
Comments
Comment #1
Syph commentedI am hiving this issue, did you ever resolve it?
Comment #2
AlexisWilke commentedSyph,
I've not been deleting products for a while... 8-}
But I'm pretty sure the bug is still there.
Alexis
Comment #3
ahimsauziMake sure that on your product kit you have a value greater than zero for the discount amount.
Not sure if that is a bug but when entering decimals in a form drupal or the discount mechanism reset value to 0.00 after saving.
Comment #4
AlexisWilke commentedahimsauzi,
And what does that have to do with deleting a product part of a kit and in your cart?
Thank you.
Alexis
Comment #5
Cablestein commentedJan 25 - 2011
Drupal 6.20, Ubercart 2.4
I have encountered this bug multiple times this week, both with my administrator account and a fresh test account, using fresh test product kits.
Overall, the main thing that seems to be happening is if you EDIT A KIT and ADD A COMPONENT to a kit, but the kit already exists in any users' cart, this is when all the problems seem to happen. The next time that user views or updates their cart, they will see varied combination of effects, like:
---Frequently happens: A red error message will appear on top of the cart page, always having to do with "Division by zero" in uc_product_kit.module around line 1113 or so --- OR --- "warning: Invalid argument supplied for foreach()" in uc_cart.module around line 1599.
---Frequently happens: Cart is completely blank. Upon clicking 'update', they will get the red error message stated above.
---Frequently happens: Cart total in cart block says something, but when viewing the cart page, the total is empty or a lot less. To put it a different way, it's like ghost products exist in your cart and you can't see them.
---Maybe happens frequently but haven't paid attention to it: For the products/kit components that are still viewable in the cart... the quantity shown will be something crazy like "0.77688" or "56.3455", or sometimes the quantity field will be completely blank.
We've tried messing around with kit component quantities, and other stuff... but have only been able to make the error happen when ADDING a component to a pre-existing kit which happens to be in someone's cart at the time of editing.
If you go back to the kit edit page, and take away that recently added component, the cart returns to normal (upon clicking Update Cart of course).
I hope this gets fixed!!
In the main time here is what we used to clear the errored cart:
This blows away the cart contents, errored or otherwise. Obviously not a solution, but maybe a helper to someone reading this.
Comment #6
longwaveIssue confirmed, not sure what the best fix is though.
Comment #7
longwaveMarked #1185120: Cart will not empty and products are unable to be removed individually. as duplicate
Comment #8
tr commentedMoving to "Product kit" component.
Comment #9
tr commentedUntagging. Only two issues had the uc_product_kit tag. Now that there's a Product kit component the tag is no longer needed.
Comment #10
arhak commented@#6
I'm not sure either
possible solution: after editing a product kit, check
uc_cart_productsand correct as neededBUT: what happens if I have a browser opened with a shopping cart page and I'm updating the quantities of my products meanwhile an admin removes an item from one of the product kits in my cart ?
Comment #11
arhak commented@#10 for the second part (an admin removes items from a PKit at the time a cart is being updated)
that can be easily handled by
uc_product_kit_update_cart_itemis just a matter of checking if that
$p_nidstill belongs to the$kitand if not set itsqtyto zeroComment #12
longwaveSimplest way to solve this seems to be to remove any matching kits from the cart whenever a kit is updated, same way we do when a kit is deleted. There is no straightforward way to handle product addition or removal at this point, so this seems safest.
Comment #14
longwave#12: 620844-uc_product_kit-update-cart.patch queued for re-testing.
Failure seems unrelated: exception 'DatabaseSchemaObjectExistsException' with message 'Table variable already exists.'
Comment #15
longwaveCommitted #12 to 7.x-3.x, ported and committed to 6.x-2.x as well.