Changeset View
Changeset View
Standalone View
Standalone View
modules/in-commerce/units/products/products_event_handler.php
Show First 20 Lines • Show All 285 Lines • ▼ Show 20 Line(s) | |||||
LEFT JOIN '.TABLE_PREFIX.'Orders ON '.TABLE_PREFIX.'Orders.OrderId = '.TABLE_PREFIX.'OrderItems.OrderId | LEFT JOIN '.TABLE_PREFIX.'Orders ON '.TABLE_PREFIX.'Orders.OrderId = '.TABLE_PREFIX.'OrderItems.OrderId | ||||
WHERE (ProductId = '.$prod_id.') AND (Quantity > QuantityReserved) AND (Status = '.ORDER_STATUS_BACKORDERS.') | WHERE (ProductId = '.$prod_id.') AND (Quantity > QuantityReserved) AND (Status = '.ORDER_STATUS_BACKORDERS.') | ||||
GROUP BY '.TABLE_PREFIX.'Orders.OrderId | GROUP BY '.TABLE_PREFIX.'Orders.OrderId | ||||
ORDER BY OrderDate ASC | ORDER BY OrderDate ASC | ||||
LIMIT 0,'.$qty; //assuming 1 item per order - minimum possible | LIMIT 0,'.$qty; //assuming 1 item per order - minimum possible | ||||
$orders = $this->Conn->GetCol($query); | $orders = $this->Conn->GetCol($query); | ||||
if (!$orders) return; | if ( !$orders ) { | ||||
return; | |||||
} | |||||
/** @var OrdersItem $order */ | |||||
$order = $this->Application->recallObject('ord.-inv', null, array('skip_autoload' => true)); | |||||
$order = $this->Application->recallObject('ord.-inv', null, Array('skip_autoload' => true)); | |||||
foreach ($orders as $ord_id) { | foreach ($orders as $ord_id) { | ||||
$order->Load($ord_id); | $order->Load($ord_id); | ||||
$this->Application->emailAdmin('BACKORDER.FULLFILL'); | $this->Application->emailAdmin('BACKORDER.FULLFILL'); | ||||
//reserve what's possible in any case | // Reserve what's possible in any case. | ||||
$event = new kEvent('ord:OnReserveItems'); | $reserve_event = new kEvent('ord:OnReserveItems'); | ||||
$this->Application->HandleEvent($event); | $this->Application->HandleEvent($reserve_event); | ||||
if ( $event->status == kEvent::erSUCCESS ) { // | // In case the order is ready to process - process it. | ||||
//in case the order is ready to process - process it | if ( $reserve_event->status == kEvent::erSUCCESS ) { | ||||
$this->Application->HandleEvent($event, 'ord:OnOrderProcess'); | $this->Application->HandleEvent(new kEvent('ord:OnOrderProcess')); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* Occurs before an item is deleted from live table when copying from temp | * Occurs before an item is deleted from live table when copying from temp | ||||
* (temp handler deleted all items from live and then copy over all items from temp) | * (temp handler deleted all items from live and then copy over all items from temp) | ||||
* Id of item being deleted is passed as event' 'id' param | * Id of item being deleted is passed as event' 'id' param | ||||
▲ Show 20 Lines • Show All 1280 Lines • Show Last 20 Lines |