<?php defined('HOSTCMS') || exit('HostCMS: access denied.'); class Kad_Shop_Observers_Paidorder { static public function onAfterChangeStatusPaid($oShopOrder, $args) { $oShopOrderItems = $oShopOrder->Shop_Order_Items; $oShopOrderItems->queryBuilder() ->where('type', '=', 0); $aoShopOrderItems = $oShopOrderItems->findAll(FALSE); $first = $oShopOrder->paid == 1 ? 1 : -1; foreach ($aoShopOrderItems as $oShopOrderItem) { $quantity = intval($oShopOrderItem->quantity); $oShopItem = $oShopOrderItem->Shop_Item; if ($oShopItem->modification_id) { $oShopItem = $oShopItem->Modification; } if (!$oShopItem->id) { continue; } $numberOrders = $oShopItem->buyed; $oShopItem->buyed = $numberOrders + $first * $quantity; $oShopItem->save(); } } } ?>
Страницу создал Вадим Гринев 30.11.16 в 12:29