private:koding:hostcms:modules:shop:order:otslezhivanie_smeny_statusa_pokupki_tovara:paidorder.php

Paidorder.php

<?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

private/koding/hostcms/modules/shop/order/otslezhivanie_smeny_statusa_pokupki_tovara/paidorder.php.txt · Last modified: 27.06.17 в 16:13 by maximzasorin_gmail.com