I've been experiencing problems with uc_fee and uc_discounts_alt line_items not being included in the total in the email sent to the customer, and in the amount sent to uc_quicpay (for creditcard charging).

This problem is somewhat hidden by the javascript adding line_items correctly - but the code that adds line_items to an order, neglects to update order total (adding the line_item amount) in the process.

I've also noticed that ubercart changes the order total on EVERY uc_order_load - also after the customer has reviewed and accepted his order.
This means, that if I change anything that makes the order total calculate in another way (I had a problem with a condition that only worked on the shop - not in admin - still don't know why) - the saved total of an old order is suddenly updated to a wrong total :)uc_order_get_total

I've also seen inifinite loops, that only stopped with an apache segfault - also initiated by the check where the total is summed up and updated if it's wrong (probably due to some module running on the hook_order - called by , that I haven't found, that calls uc_order_load - causing the loop).

I've attached a patch that removes the IMHO bad behavior of updating orders on load - and makes the line_item alter functions (add, delete, update) also correct the order total.

It works like a charm on my install.

CommentFileSizeAuthor
ubercart-uc_order.patch2.48 KBklavs

Comments

tr’s picture

Status: Active » Postponed (maintainer needs more info)

No, can't do that. It's vital that the order total be recalculated using the info stored in the database, since values posted in the form or over Ajax could be subject to manipulation and can not be trusted. Likewise, it's extremely important that the values in the order reflect the current state of the database, including recent price changes etc., and that it not be determined solely by cart information that may have been set days or months prior.

You are talking about several distinct issues here. First is a problem with uc_fee/uc_discounts_alt that should be addressed in the issue queue for those modules. Second is what you say about the JavaScript not adding line_items correctly - that is an issue in and of itself, but it's not clear at this point that it's a bug. Much more information is needed. If you think some of the JavaScript is wrong, please let us know where you think this error is and why the current code is wrong. The responsibility for calculating an order total should never lie with the JavaScript, as that would be subject to client manipulation.

Likewise the issue about infinite loops is distinct from the other issues, and since it is obviously not something that everyone sees it is highly likely to be caused by one of the contributed modules you have installed. In order to address this issue you need to provide enough information for us to reproduce the error - what steps are you taking leading to this result? Does it go away when you turn off your contributed modules? Please narrow it down.

Please separate your problems into separate issues so they can be looked at and worked on separately.

longwave’s picture

Status: Postponed (maintainer needs more info) » Closed (works as designed)

No response in several months, presuming this is no longer an issue. Please reopen if more info is available.