Ubercart bug duplicates order products and the wonders of open source

So, open source eh? Full of bugs? Perhaps. But at least you can fix them if you try hard enough.
There's a really annoying bug in Ubercart 2.3 that doubles up products in an order every time you try to add more products. The same also happens when you try and delete products from the order. So you end up with a very large and expensive order. Not good.
I spent the last 2 and a half hours digging through the code and found it was doing a save before adding the products. Then it does another save.
This means there are 2 saves when there should really only be one. The line items were therefore multiplying every time a new action of add or remove was called. Very annoying!
I edited this file...
uc_order.admin.inc
And commented out this section in function "uc_order_edit_products"...
if (is_array($_POST['products'])) {
foreach ($_POST['products'] as $key => $product) {
$product['data'] = unserialize($product['data']);
uc_order_product_save($order->order_id, (object) $product);
}
}
Line 1290 of ubercart/uc_order/uc_order.admin.inc [Ubercart Version 2.3]
I haven't tested it extensively, but it appears to work... so test passed! Hah. Next!

Comments