omega13a Posted March 22, 2006 Posted March 22, 2006 I'm trying to write a new order total module. However, it just won't install from the admin panel. >_< I click install and nothing happens. :huh: Can anyone help me here? :sweating: Here's the code if it is off any help: <?php class ot_authorization_code { var $code; var $title; var $description; var $enabled; var $sort_order; var $output; var $deduction; var $check; function ot_authorization_code() { $this->code = "ot_authorization_code"; $this->title = 'Pre-Registered Class(es)'; $this->description = "If you are signing up as part of a mass registration, please enter your authorization code"; $this->enabled = true; $this->sort_order = 741; $this->output = array(); } function process() { global $PHP_SELF, $order, $currencies; $order_total = $this->get_order_total(); $od_amount = $this->calculate_credit($order_total); $tod_amount = 0.0; $this->deduction = $od_amount; if ($od_amount > 0) { $order->info['total'] = $order->info['total'] - $od_amount; $this->output[] = array('title' => $this->title . ':', 'text' => '<b>-' . $currencies->format($od_amount) . '</b>', 'value' => $od_amount); } } function check() { $check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_ORDER_TOTAL_AUTHORIZATION_CODE_STATUS'"); $this->check = tep_db_num_rows($check_query); return $this->check; } function keys() { return array( 'MODULE_ORDER_TOTAL_AUTHORIZATION_CODE_STATUS', 'MODULE_ORDER_TOTAL_AUTHORIZATION_CODE_SORT_ORDER', ); } function install() { tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Allow Auth Code', 'MODULE_ORDER_TOTAL_AUTHORIZATION_CODE_STATUS', 'true', 'Do you want to display the auth code?', '6', '1','tep_cfg_select_option(array(\'true\', \'false\'), ', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Sort Order', 'MODULE_ORDER_TOTAL_AUTHORIZATION_CODE_SORT_ORDER', '10', 'Sort order of display.', '6', '2', '', now())"); } function remove() { $keys = ''; $keys_array = $this->keys(); for ($i=0; $i<sizeof($keys_array); $i++) { $keys .= "'" . $keys_array[$i] . "',"; } $keys = substr($keys, 0, -1); tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in (" . $keys . ")"); } function get_order_total() { global $order, $cart, $customer_id, $auth_code; $order_total = $order->info['total']; $products = $cart->get_products(); for ($i=0; $i<sizeof($products); $i++) { $t_prid = tep_get_prid($products[$i]['id']); $gv_query = tep_db_query("select products_price, products_tax_class_id, products_model from " . TABLE_PRODUCTS . " where products_id = '" . $t_prid . "'"); $gv_result = tep_db_fetch_array($gv_query); $query2 = tep_db_query("SELECT * FROM lto_coupon_master WHERE course_sequence = '".$products[$i]['id']."'"); $num = tep_db_num_rows($query2); if ($num > 0) { while ($row = tep_db_fetch_array($query2)) { if ($row['coupon_desc'] == $auth_code && !empty($auth_code)) { $query3 = tep_db_query("SELECT * FROM lto_company_course_participant_xref WHERE coupon_code = '".$_COOKIE['account_info']['coupon_code']."'"); while ($row3 = tep_db_fetch_array($query3)) { if ($row3['total_seats_remaining'] > 0) { $order_total = $order_total - $gv_result['products_price']; break 3; } } } } } } return $order_total; } function calculate_credit($order_total) { global $order; $amount = $order->info['total'] - $order_total; return $amount; } function credit_selection() { global $customer_id, $currencies, $language; $selection_string = ""; $selection_string .= '' . "\n"; $selection_string .= ' </tr><tr><td class="main">' . "\n"; $selection_string .= "Enter your authorisation code (if you have one):" . tep_draw_input_field('auth_code') . ' and click '; $image_submit = '<input type="button" name="submit_auth_code" onClick="return check_form(), submitFunction()" value="Here" />'; $selection_string .= '' . $image_submit . '</td>'; $selection_string .= ''; $selection_string .= '' . "\n"; return $selection_string; } function use_credit_amount() { return $output_string; } function collect_posts() { global $HTTP_POST_VARS, $customer_id, $currencies, $auth_code; global $order, $cart; if (isset($HTTP_POST_VARS['auth_code']) AND !empty($HTTP_POST_VARS['auth_code'])) { $found = false; $products = $cart->get_products(); for ($i=0; $i < sizeof($products); $i++) { $query = tep_db_query("SELECT * FROM lto_coupon_master WHERE course_sequence = '".$products[$i]['id']."'"); $num = tep_db_num_rows($query2); if ($num > 0) { while ($row = tep_db_fetch_array($query2)) { if ($row['coupon_desc'] == $HTTP_POST_VARS['auth_code'] && !empty($HTTP_POST_VARS['auth_code'])) { $query3 = tep_db_query("SELECT * FROM lto_company_course_participant_xref WHERE coupon_code = '".$_COOKIE['account_info']['coupon_code']."'"); while ($row3 = tep_db_fetch_array($query3)) { if ($row3['total_seats_remaining'] > 0) { $found = true; tep_session_register('auth_code'); $auth_code = $HTTP_POST_VARS['auth_code']; break 3; } } } } } } if (!$found) { $err_msg = "Auth Code Not Valid"; tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'payment_error='.$this->code.'&error=' . urlencode($err_msg), 'SSL')); } } } } ?> Quote A Fish Without A Bicycle Cannot Contemplate His Navel.
Guest Posted March 25, 2006 Posted March 25, 2006 (edited) Your files must be named ot_authorization_code.php - you *must* have a corresponding language file. It installs fine for me, but I have not tested it further. Please remember to put the osCommerce copyright notice and your own copyright notice in the files :) Please be sure to upload it as a contribution. Matti Edited March 25, 2006 by Johnson Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.