There is $order->data['last_cart_refresh'] property which are used in commerce_cart_order_can_refresh() to limit refreshing by time.
Problem is that this property is set only in cart functionality ( commerce_cart_product_add() ) and after refreshing - but do not set in backoffice manual order creation.
So, if order created manually, order always will be refreshed.

Comments

Evgeny_Yudkin created an issue. See original summary.

Evgeny_Yudkin’s picture

Evgeny_Yudkin’s picture

Status: Active » Needs review

Status: Needs review » Needs work
Evgeny_Yudkin’s picture

Evgeny_Yudkin’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work
Evgeny_Yudkin’s picture

Version: 7.x-1.11 » 7.x-1.x-dev

Status: Needs work » Needs review
Evgeny_Yudkin’s picture

rszrama’s picture

Title: Last_cart_refresh does not set in manual order creation (from BO) » Move the set of last_cart_refresh in the order data array
Component: Order » Cart
Assigned: Evgeny_Yudkin » Unassigned
Category: Bug report » Task
Status: Needs review » Active

This is actually an inappropriate fix, because the Order module / form isn't concerned with cart orders or refreshes. From the back office, the solution would really be to just set a status other than shopping cart - otherwise, the mere act of submitting the form doesn't refresh the prices but the subsequent load.

One thing we could do is move the setting of the variable in the order's data array into the refresh function itself (as opposed to the order load hook). This would ensure the variable gets set when the form used to trigger a manual order refresh is submitted.

IRuslan’s picture

I think the patch make sense, conditions if order in the cart are dynamic because of
foreach (module_implements('commerce_cart_order_is_cart') as $module) {
in commerce_cart_order_is_cart(). So it could vary depending from the site configuration.
And in same time we need to ensure that last_refresh properly set up during creation.
Approach in the patch follows consistency with approach in commerce_cart_product_add() — set value at the moment when actually order saved with some products added.

Just as improvement probably also make sense to set up order's data variable in order presave phase, during creation — else, just created order always will fall inside commerce_cart_order_can_refresh() conditions.