The admin order edit page allows administrators to add products to existing orders and to remove them. However, when you add or remove a product, all products are duplicated.

I did some digging and discovered the cause was that product fields marked as hidden do not end up in the product form. This is a problem because uc_order_product_save inserts new entries for every product in $_POST for which order_product_id is not set. And since order_product_id is a hidden field, it does not end up in $_POST causing every product to be inserted rather than updated.

The best, quickest and least painful solution I could come up with was to move the hidden fields for every row in the product form underneath a field that is visible, as in the attached patch.

However, if there's a better solution, and one that does not involve modifying core Ubercart core, I'd love to hear about it so I can implement that instead.

CommentFileSizeAuthor
uc_order.admin_.patch2.62 KBrhmtts

Comments

rhmtts’s picture

Priority: Major » Minor
Status: Needs review » Closed (cannot reproduce)

Apparently something in our install had secretly become broken.

It works now. Without any patch whatsoever.

jbarns’s picture

what did you do to fix it? just reinstall?

I don't want to lose data if I uninstall. I will backup but its a big headache.

rhmtts’s picture

As best as I can tell a colleague updating some modules (VAT, I believe) fixed it.

javlinsharp’s picture

rhmtts,
Ive been having this same issue but your patch worked for me.
Thanks a ton...

Still concerned about "branching the code" with this patch though. I hope UC team will review the code and merge it, thereby removing upgrade anxiety.

Thanks again

rhmtts’s picture

The patch works, I'm sure of that, but after "something" was updated by "a colleague" it was no longer needed. Maybe you could try to update all your modules and remove the patch to see if that solves the problem for you as well. If it does, the issue is probably not worth looking into any further. If it doesn't, something in uc_order.admin is still broken.

tobiberlin’s picture

had the same issue, patch solved it