public function changeOrderStatusHook($status_id, $comment, $order_id) { $newComment = ''; error_log("IN ORDER STATUS HOOK", E_USER_ERROR); $this->load->model('sale/order'); $this->load->model('localisation/order_status'); $order_status_info = $this->model_localisation_order_status->getOrderStatus($status_id); if ($order_status_info) { $data['order_status'] = $order_status_info['name']; } else { $data['order_status'] = ''; } opencart_invfox__trace($data['order_status']); $invoicefox_id = $this->model_sale_order->getInvoicefoxId($order_id); if ($data['order_status'] == $this->CONF['create_invfox_document_on_status'] && $invoicefox_id == '') { $newComment = $this->makeInvoiceFromOrder($order_id); error_log("IN ORDER STATUS HOOK END", E_USER_ERROR); } if ($data['order_status'] == $this->CONF['close_invfox_document_on_status']) { $api = new InvfoxAPI($this->CONF['API_KEY'], $this->CONF['API_DOMAIN'], true); $api->setDebugHook("opencart_invfox__trace"); $this->load->model('sale/order'); $order = $this->model_sale_order->getOrder($order_id); $invoice_no = $this->CONF['use_shop_document_numbers'] ? $order['invoice_prefix'] . $order['order_id'] : '-'; $r = $api->markInvoicePaid($order['order_id']); error_log("IN ORDER STATUS HOOK END", E_USER_ERROR); } return $comment . ($comment ? "\n\n" : "") . $newComment; }