name = 'ant_refund'; $this->tab = 'administration'; $this->author = 'Antadis'; $this->version = '1.0'; $this->need_instance = 0; parent::__construct(); $this->displayName = $this->l('Refund for non fraud order'); $this->description = $this->l('Creating refund when order status is changing to non fraud'); } public function install() { # Register hooks if(!(parent::install() && $this->registerHook('afterChangeStatus'))) { return false; } return true; } public function hookafterChangeStatus($params) { if (!$params['newOrderState']) { return false; } $orderState = (int) $params['newOrderState']; if ($orderState == 15 || $orderState == 16) { $order = new Order((int) $params['order']['id']); if (Validate::isLoadedObject($order) ) { $customer = new Customer((int)($order->id_customer)); /* PRODUITS REMBOURSES */ $full_quantity_list = array(); $full_product_list = array(); foreach(Db::getInstance()->ExecuteS(' SELECT d.`id_order_detail`, d.`product_quantity` FROM `'._DB_PREFIX_.'order_detail` d LEFT JOIN `'._DB_PREFIX_.'orders` o ON d.`id_order` = o.`id_order` WHERE d.`id_order` = '.(int) $params['id_order'].' ') as $row) { $full_quantity_list[$row['id_order_detail']] = $row['product_quantity']; $full_product_list[$row['id_order_detail']] = $row['id_order_detail']; } if (!OrderSlip::createOrderSlip($order, $full_product_list, $full_quantity_list, true)) { $this->_errors[] = Tools::displayError('Cannot generate credit slip'); } else { Module::hookExec('orderSlip', array('order' => $order, 'productList' => $full_product_list, 'qtyList' => $full_quantity_list)); } } } } }