VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: OpenGlobal on June 04, 2012, 19:15:39 PM

Title: Duplicate lines in cart for custom plugins
Post by: OpenGlobal on June 04, 2012, 19:15:39 PM
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
Title: Re: Duplicate lines in cart for custom plugins
Post by: UWiX on September 07, 2013, 14:54:27 PM
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 ;-)
Title: Re: Duplicate lines in cart for custom plugins
Post by: Milbo on September 08, 2013, 16:57:51 PM
is solved in vm2.1, I wont touch this in vm2.0