code = 'ot_cmembers'; $this->title = $aLang['module_cmembers_title']; $this->description = $aLang['module_cmembers_description']; $this->enabled = (defined('MODULE_CMEMBERS_STATUS') && (MODULE_CMEMBERS_STATUS == 'true') ? TRUE : FALSE); $this->sort_order = (defined('MODULE_CMEMBERS_SORT_ORDER') ? MODULE_CMEMBERS_SORT_ORDER : null); $this->include_shipping = (defined('MODULE_CMEMBERS_INC_SHIPPING') ? MODULE_CMEMBERS_INC_SHIPPING : null); $this->include_tax = (defined('MODULE_CMEMBERS_INC_TAX') ? MODULE_CMEMBERS_INC_TAX : null); $this->calculate_tax = (defined('MODULE_CMEMBERS_CALC_TAX') ? MODULE_CMEMBERS_CALC_TAX : null); $this->percentage = (defined('MODULE_CMEMBERS_OT_DISCOUNT') ? MODULE_CMEMBERS_OT_DISCOUNT : null); $this->output = array(); } function process() { global $oOrder, $oCurrencies; $od_amount = $this->calculate_credit($this->get_order_total()); if ($od_amount>0) { $this->deduction = $od_amount; $this->output[] = array('title' => '- ' . $this->title . ' ('. number_format($this->percentage, 2) .'%):', 'text' => '' . $oCurrencies->format($od_amount) . '', 'value' => $od_amount); $oOrder->info['total'] = $oOrder->info['total'] - $od_amount; } } function calculate_credit($amount) { global $oOrder, $customer_id, $customer_status_value; $od_amount=0; $od_pc = $this->percentage; $cart_count = $_SESSION['cart']->count_contents(); if (MODULE_CMEMBERS_CART_COUNT < $cart_count) { if ($this->calculate_tax == 'true') { // Calculate main tax reduction $tod_amount = round($oOrder->info['tax']*10)/10*$od_pc/100; $oOrder->info['tax'] = $oOrder->info['tax'] - $tod_amount; // Calculate tax group deductions reset($oOrder->info['tax_groups']); foreach($oOrder->info['tax_groups'] as $key => $value) { $god_amount = round($value*10)/10*$od_pc/100; $oOrder->info['tax_groups'][$key] = $oOrder->info['tax_groups'][$key] - $god_amount; } } $od_amount = round($amount*10)/10*$od_pc/100; $od_amount = $od_amount + $tod_amount; } return $od_amount; } function get_order_total() { global $oOrder; $order_total = $oOrder->info['total']; // Check if gift voucher is in cart and adjust total $products = $_SESSION['cart']->get_products(); for ($i=0; $iGetRow($query); if (preg_match('/^GIFT/', addslashes($gv_result['products_model']))) { $qty = $_SESSION['cart']->get_quantity($t_prid); $products_tax = oos_get_tax_rate($gv_result['products_tax_class_id']); if ($this->include_tax =='false') { $gv_amount = $gv_result['products_price'] * $qty; } else { $gv_amount = ($gv_result['products_price'] + oos_calculate_tax($gv_result['products_price'],$products_tax)) * $qty; } $order_total = $order_total - $gv_amount; } } if ($this->include_tax == 'false') $order_total = $order_total-$oOrder->info['tax']; if ($this->include_shipping == 'false') $order_total = $order_total-$oOrder->info['shipping_cost']; return $order_total; } function check() { if (!isset($this->_check)) { $this->_check = defined('MODULE_CMEMBERS_STATUS'); } return $this->_check; } function keys() { return array('MODULE_CMEMBERS_STATUS', 'MODULE_CMEMBERS_SORT_ORDER', 'MODULE_CMEMBERS_CART_COUNT', 'MODULE_CMEMBERS_OT_DISCOUNT', 'MODULE_CMEMBERS_INC_SHIPPING', 'MODULE_CMEMBERS_INC_TAX', 'MODULE_CMEMBERS_CALC_TAX'); } function install() { // Get database information $dbconn =& oosDBGetConn(); $oostable =& oosDBGetTables(); $configurationtable = $oostable['configuration']; $dbconn->Execute("INSERT INTO $configurationtable (configuration_key, configuration_value, configuration_group_id, sort_order, set_function, date_added) values ('MODULE_CMEMBERS_STATUS', 'true', '6', '1','oos_cfg_select_option(array(\'true\', \'false\'), ', now())"); $dbconn->Execute("INSERT INTO $configurationtable (configuration_key, configuration_value, configuration_group_id, sort_order, date_added) values ('MODULE_CMEMBERS_SORT_ORDER', '12', '6', '2', now())"); $dbconn->Execute("INSERT INTO $configurationtable (configuration_key, configuration_value, configuration_group_id, sort_order, date_added) values ('MODULE_CMEMBERS_CART_COUNT', '5', '6', '3', now())"); $dbconn->Execute("INSERT INTO $configurationtable (configuration_key, configuration_value, configuration_group_id, sort_order, date_added) values ('MODULE_CMEMBERS_OT_DISCOUNT', '10', '6', '4', now())"); $dbconn->Execute("INSERT INTO $configurationtable (configuration_key, configuration_value, configuration_group_id, sort_order, set_function ,date_added) values ('MODULE_CMEMBERS_INC_SHIPPING', 'true', '6', '5', 'oos_cfg_select_option(array(\'true\', \'false\'), ', now())"); $dbconn->Execute("INSERT INTO $configurationtable (configuration_key, configuration_value, configuration_group_id, sort_order, set_function ,date_added) values ('MODULE_CMEMBERS_INC_TAX', 'true', '6', '6','oos_cfg_select_option(array(\'true\', \'false\'), ', now())"); $dbconn->Execute("INSERT INTO $configurationtable (configuration_key, configuration_value, configuration_group_id, sort_order, set_function ,date_added) values ('MODULE_CMEMBERS_CALC_TAX', 'false', '6', '7','oos_cfg_select_option(array(\'true\', \'false\'), ', now())"); } function remove() { // Get database information $dbconn =& oosDBGetConn(); $oostable =& oosDBGetTables(); $configurationtable = $oostable['configuration']; $dbconn->Execute("DELETE FROM $configurationtable WHERE configuration_key in ('" . implode("', '", $this->keys()) . "')"); } }