Child pages
  • [in-commerce] Duplicate Sub-Total calculation code [5.2.1]
Skip to end of metadata
Go to start of metadata

Following code in the "orditems:OnUpdate" event

if ( $this->Application->GetVar('t') != 'in-commerce/orders/orders_edit_items' ) {

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

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

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

is invoked when order contents is saved from the "Items" tab during order editing in Admin Console. This code calculates values for following order fields:

  • SubTotal
  • ReturnTotal

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).


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

Related Tasks