public function hookadminOrder($params) { if (!$this->active) { return false; } $order = new Order($params['id_order']); if ($order->module != $this->name) { return false; } $cart = new Cart((int) $order->id_cart); $interpay_order = Db::getInstance()->getRow('SELECT * FROM `' . _DB_PREFIX_ . 'gointerpay_order_id` WHERE `id_cart` = ' . (int) $order->id_cart); include_once _PS_MODULE_DIR_ . 'gointerpay/Rest.php'; $rest = new Rest(Configuration::get('GOINTERPAY_STORE'), Configuration::get('GOINTERPAY_SECRET')); $result = $rest->orderDetail(Tools::safeOutput($interpay_order['orderId'])); if ($order->getCurrentState() == Configuration::get('PS_OS_CANCELED') && $interpay_order['status'] != 'Cancel') { $result = $rest->updateOrderStatus($interpay_order['orderId'], 'VENDOR_CANCELLATION_REQUEST'); Db::getInstance()->Execute('UPDATE `' . _DB_PREFIX_ . 'gointerpay_order_id` SET `status` = \'Cancel\' WHERE `id_cart` = ' . (int) $order->id_cart); $interpay_order['status'] = 'Cancel'; $this->context->smarty->assign('interpay_validate', $this->l('Request sent to IGlobal to cancel the order')); } else { if ($order->getCurrentState() == Configuration::get('PS_OS_PAYMENT') && $interpay_order['status'] != 'Accepted') { $result = $rest->updateOrderStatus($interpay_order['orderId'], 'VENDOR_PREPARING_ORDER'); Db::getInstance()->Execute('UPDATE `' . _DB_PREFIX_ . 'gointerpay_order_id` SET `status` = \'Accepted\' WHERE `id_cart` = ' . (int) $order->id_cart); $interpay_order['status'] = 'Accepted'; $this->context->smarty->assign('interpay_validate', $this->l('Order accepted in Gointerpay')); } else { if ($order->getCurrentState() == Configuration::get('PS_OS_SHIPPING') && $interpay_order['status'] != 'Shipped') { $result = $rest->updateOrderStatus($interpay_order['orderId'], '400', true); Db::getInstance()->Execute('UPDATE `' . _DB_PREFIX_ . 'gointerpay_order_id` SET `status` = \'Shipped\' WHERE `id_cart` = ' . (int) $order->id_cart); $interpay_order['status'] = 'Shipped'; $this->context->smarty->assign('interpay_validate', $this->l('Order updated in Gointerpay')); } } } $message = array(); if ($interpay_order['status'] == 'Pending') { $message[] = $this->l('You can accept this order by updating the status to "Payment accepted" or cancel it by updating the status to "Canceled".'); $interpay_status[] = (int) Configuration::get('PS_OS_PAYMENT'); $interpay_status[] = (int) Configuration::get('PS_OS_CANCELED'); } elseif ($interpay_order['status'] == 'Accepted') { $message[] = $this->l('Once this order has been shipped, please update the order status to "Shipped".'); $message[] = $this->l('You can also cancel the order by updating the status to "Canceled".'); $interpay_status[] = (int) Configuration::get('PS_OS_SHIPPING'); $interpay_status[] = (int) Configuration::get('PS_OS_CANCELED'); } elseif ($interpay_order['status'] == 'Cancel') { $message[] = $this->l('This order has been marked as cancelled.'); } elseif ($interpay_order['status'] == 'Shipped') { $message[] = $this->l('This order has been marked as shipped.'); } $interpay_status[] = Configuration::get('PS_OS_REFUND'); $this->context->smarty->assign(array('interpay_message' => $message, 'interpay_order' => $interpay_order, 'interpay_link' => $rest->getOrderStatusLink(Tools::safeOutput($interpay_order['orderId'])), 'interpay_status' => Tools::jsonEncode(array('available' => $interpay_status)))); return $this->display(__FILE__, 'tpl/order.tpl'); }