Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Following code in the "orditems:OnUpdate" event

Code Block
firstline143
titleorder_items_event_handler.phpfirstline143
linenumberstrue
if ( $this->Application->GetVar('t') != 'in-commerce/orders/orders_edit_items' ) {
   return;
}

$sub_total = $this->getSubTotal($items_info);

if ( $sub_total !== false ) {
   $main_object->SetDBField('SubTotal', $sub_total);
}

$main_object->SetDBField('ReturnTotal', $this->getReturnTotal($items_info));
$main_object->Update();

...

What's wrong with this code is that SubTotal is also calculated in the "ord:OnRecalculateItems" event, which called on any order update (this one included).

Solution

  1. move "ReturnTotal" field calculation to the OrderManager::setOrderTotals method
  2. remove above mentioned code from orditems:OnUpdate event

Related Tasks