code = 'ot_charges'; $this->title = $aLang['module_charges_title']; $this->description = $aLang['module_charges_description']; $this->enabled = MODULE_CHARGES_STATUS; $this->sort_order = MODULE_CHARGES_SORT_ORDER; $this->percentage = MODULE_CHARGES_CHARGES; $this->output = array(); } function process() { global $order, $oCurrencies; $charges = $this->percentage; $order_total = $order->info['total']; $add_charges = $this->calculate_credit($order_total); if ($add_charges>0) { $this->deduction = $add_charges; $this->output[] = array('title' => '+ ' . $this->title . ' ('. number_format($charges, 2) .'%): ', 'text' => '' . $oCurrencies->format($add_charges) . '', 'value' => $add_charges); $order->info['total'] = $order->info['total'] + $add_charges; } } function calculate_credit($amount) { $add_charges = 0; $od_pc = $this->percentage; if ($_SESSION['payment'] == 'payment') { $add_charges = round($amount*10)/10*$od_pc/100; } return $add_charges; } function check() { if (!isset($this->check)) { $db =& oosDBGetConn(); $oosDBTable = oosDBGetTables(); $check_result = $db->Execute("SELECT configuration_value FROM " . $oosDBTable['configuration'] . " WHERE configuration_key = 'MODULE_CHARGES_STATUS'"); $this->check = $check_result->RecordCount(); } return $this->check; } function keys() { return array('MODULE_CHARGES_STATUS', 'MODULE_CHARGES_SORT_ORDER', 'MODULE_CHARGES_CHARGES'); } function install() { $db =& oosDBGetConn(); $oosDBTable = oosDBGetTables(); $db->Execute("INSERT INTO " . $oosDBTable['configuration'] . " (configuration_key, configuration_value, configuration_group_id, sort_order, set_function, date_added) values ('MODULE_CHARGES_STATUS', 'true', '6', '1','oosCfgSelectOption(array(\'true\', \'false\'), ', now())"); $db->Execute("INSERT INTO " . $oosDBTable['configuration'] . " (configuration_key, configuration_value, configuration_group_id, sort_order, date_added) values ('MODULE_CHARGES_SORT_ORDER', '10', '6', '2', now())"); $db->Execute("INSERT INTO " . $oosDBTable['configuration'] . " (configuration_key, configuration_value, configuration_group_id, sort_order, date_added) values ('MODULE_CHARGES_CHARGES', '3', '6', '2', now())"); } function remove() { $db =& oosDBGetConn(); $oosDBTable = oosDBGetTables(); $db->Execute("DELETE FROM " . $oosDBTable['configuration'] . " WHERE configuration_key in ('" . implode("', '", $this->keys()) . "')"); } } ?>