| Project: | Ubercart Contributions |
| Component: | Code |
| Category: | |
| Priority: | minor |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
There is a query in uc_shipping that perhaps doesn't account for everything one would expect it to. It is in the function uc_shipping_order_packages().
The query is: "SELECT op.order_product_id, SUM(op.qty) AS total, SUM(pp.qty) AS packaged FROM {uc_order_products} AS op LEFT JOIN {uc_packaged_products} AS pp ON op.order_product_id = pp.order_product_id WHERE op.order_id = %d GROUP BY op.order_product_id HAVING SUM(pp.qty) IS NULL OR SUM(op.qty) > SUM(pp.qty)"
This query appears to determine if the "Create Packages" link should appear and in many cases does as it should and prevents it from showing up when all products in an order are packaged. I noticed, however, that when an order contains a product with a quantity other than 1 it doesn't work as expected. Consider this scenario to see problem. An order contains 2 of product X. If 2 packages are created, each containing one product X, the "create packages" button should disappear, as all items are packaged. It doesn't, however, because the aforementioned query's use of SUM(op.qty) results in a value double what it should, because it is being JOINED with the uc_packaged_products table in which there are two rows (packages) that correspond to the one product (product X). SUM(op.qty) then returns a value double what it should and in the comparison at the end of query it looks like all of the product is not packaged. I would rewrite this query for you, but I'm unsure how this can be corrected. Perhaps it can't be done with one query. Eitherway, it's not a huge issue and I hope I explained it properly.
Thanks.

