News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Duplicate lines in cart for custom plugins

Started by OpenGlobal, June 04, 2012, 19:15:39 PM

Previous topic - Next topic

OpenGlobal

This was spotted with the stockable variant custom plugin but looking at the code, it should apply to all custom plugins.

If someone adds a custom plugin variant product to their cart twice (ie "Add to Cart", then go back and "Add to Cart" again), this results in two identical lines in the cart rather than one line with a quantity of 2.

Looking at administrator/...../helpers/cart.php the following code makes the $productKey unique every time the Add to Cart button is pressed:


                                        if ( !empty($product->customPlugin)) {
                                                $productKey .= count($this->products);

                                        }


I think it would be better if the plgVmOnAddToCart() event call sent the $productKey as well so that this could be modified or not, as the plugin requires. Or alternatively, call another event handler in the plugin to modify the $productKey. Maybe plgVmOnAddToCartQuantity() or something like that.

OpenGlobal

UWiX

This is indeed a hard thing to solve. When using the plgVmOnAddToCart function to set the $product->customPlugin to null/zero/nothing the product get's indeed added but without the extra customPlugin parameters.

Any suggestions to bypass this 'problem' without the need to manually change the cart.php code?

Good ideas are welcome ;-)
-- Beam me up Scotty! This isn't the mens room!
-- Using VirtueMart 3.x

Milbo

is solved in vm2.1, I wont touch this in vm2.0
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/