/** * @param array $results */ protected function finish($results) { $order = $this->_orders[$results['orderNum'] - 1]; if (!Orders::getInstance()->assignWarehouse($order)) { echo "No warehouses have enough stock for this order!\n"; } else { echo "Warehouse assigned successfully.\n"; } }
/** * @param array $results */ protected function finish($results) { $order = $this->_orders[$results['orderNum'] - 1]; $product = $this->_products[$results['productNum'] - 1]; $order->addProduct($product); Orders::getInstance()->save($order); echo "Product added to order successfully.\n"; }
/** * Assign a warehouse based on stock availability and distance from order * @param Order $order * @return bool */ public function assignWarehouse($order) { $warehouseId = $this->findWarehouse($order); if (!$warehouseId) { return false; } $order->setWarehouseId($warehouseId); Orders::getInstance()->save($order); return true; }
/** * @param array $results */ protected function finish($results) { $product = new Order($results); Orders::getInstance()->save($product); echo "Order added successfully.\n"; }