make sure we get the current order for use in the cart as well. Refactored some shared code as well.

Fixes #5300