shaggy2dope2125 Posted October 6, 2005 Share Posted October 6, 2005 (edited) every time i try to install my module, nothing happens, the page refreshes, but nothing is displayed about it being install. here is the code if it helps <?php /* $Id: item_model.php, V 1.0 2005/14.09 05:03:31 hpd1 Exp $ Written by Kevin Myers, [email protected] osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright ? 2003 osCommerce Copyright ? 2005 Magickoncepts.com Released under the GNU General Public Licensee */ class item_model { var $code, $title, $description, $icon, $enabled, $num_zones; // class constructor function item_model() { global $order; $this->code = 'item_model'; $this->title = MODULE_SHIPPING_ITEM_MODEL_TEXT_TITLE; $this->description = MODULE_SHIPPING_ITEM_MODEL_TEXT_DESCRIPTION; $this->sort_order = MODULE_SHIPPING_ITEM_MODEL_SORT_ODER; $this->icon = ''; $this->tax_class = MODULE_SHIPPING_ITEM_MODEL_TAX_CLASS; $this->enabled = ((MODULE_SHIPPING_ITEM_MODEL_STATUS == 'True') ? true : false); $this->num_zones = 5; if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_ITEM_MODEL_ZONE > 0) ) { $check_flag = false; $check_query = tep_db_query("SELECT zone_id FROM " . TABLE_ZONE__TO_GEO_ZONES . " WHERE geo_zone_id = '" . MODULE_SHIPPING_ITEM_MODEL_ZONE . "' and zone_county_id '" . $order->delivery['country']['id'] . "' ORDER BY zode_id"); while ($check = tep_fetch_array($check_query)) { if ($check['zone_id'] < 1) { $check_flag = true; break; } elseif ($check['zone_id'] == $order->delivery['zone_id']) { $check_flag = true; break; } } if ($check_flag == false) { $this->enabled = false; } } } // class methods function quote($method = ''){ global $order, $total_count, $order_id; $dest_country = $oder->delivery['country']['iso_code_2']; $dest_zone = 0; $error1 = false; $error2 = false; for ($i=1; $s<=$this->num_zones; $i++) { $countries_table = constant(MODULE_SHIPPING_ITEM_MODEL_COUNTRIES_ . $i); $country_zones = split("[,]", $countries_table); if(in_Array($dest_country, $country_zones)) { $dest_zone = $i; break; }//ends if statement }//ends for loop if ($dest_zone == 0) { for ($i=1; $i<=$this->num_zones; $i++) { $countries_table = constant(MODULE_SHIPPING_ITEM_MODEL_COUNTRIES_ . $i); if ($countries_table == '' or $countries_table == '*') { $dest_zone = $i; break; } } } if ($dest_zone == 0) { $error1 = true; } $orders_products_query = tep_db_query("SELECT orders_products_id, products_id, products_name, products_model, products_price, products_tax, products_quantity, final_price FROM ". TABLE_ORDERS_PRODUCTS . " WHERE orders_id = '" . (int)$orders_id ."'"); $num_orders = mysql_num_rows($orders_products_query); $x = 0; while($orders_products = tep_db_fetch_array($orders_product_query)) { $this->products[$x] = array( 'qty' => $orders_products['products_quantity'], 'id' => $orders_products['products_id'], 'name' => $orders_products['products_name'], 'model' => $orders_products['products_model'], 'tax' => $orders_products['products_tax'], 'price' => $orders_products['produacts_price'], 'final_price' => $orders_products['final_price']); $x++; } for($X = 0; $X <= $num_orders; $X++) { if($this->products[$X]['model'] == 'single') { $singles_count++; } elseif($this->products[$X]['model'] == 'box') { $box_count++; } elseif($this->products[$X]['model'] == 'set') { $set_count++; } elseif($this->products[$X]['model'] == 'deck') { $deck_count++; } elseif($this->products[$X]['model'] == 'lot') { $lot_count++; } } if($singles_count < "30") { $shipping_singles = 1; } else { $shipping_singles = 1 + ($shipping_count - "30")* ".1"; } $shipping_box = $box_count * 5; $shipping_set = $set_count * 7.50; $shipping_deck = $deck_count * 2.50; $shipping_lot = $lot_count * 4; $shipping_total = $shipping_singles + $shipping_box + $shipping_set + $shipping_deck + $shipping_lot; //this is where i set up the additional charge for each "zone" if($dest_zone == 1) { $shipping_total = $shipping_total; } elseif($dest_zone == 2) { $shipping_total = $shipping_total + ($shipping_total * .02); } elseif($dest_zone == 3) { $shipping_total = $shipping_total + ($shipping_total * .025); } elseif($dest_zone == 4) { $shipping_total = $shipping_total + ($shipping_total * .03); } elseif($dest_zone == 5) { $shipping_total = $shipping_total + ($shipping_total * .045); }//this ends the shipping totals for each zone define ("MODULE_SHIPPING_ITEM_MODEL_COST", $shipping_total); $this->quotes = array('id' => $this->code, 'module' => MODULE_SHIPPING_ITEM_MODEL_TEXT_TITLE, 'methodes' => array(array('id' => $this->code, 'title' => MODULE_SHIPPING_ITEM_MODEL_TEXT_WAY, //this is the point that i need to figure out if the items are singles or boxes 'cost' => MODULE_SHIPPING_ITEM_MODEL_COST )//closes second array )//closes first aray );//closes the qutes array if ($this->tax_class > 0) { $this->quotes['tax'] = tep_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_ir']); } if (tep_not_null($this->icon)) $this->quotes['icon'] = tep_image($this->icon, $this->title); return $this->quotes; }//ends the quote functions function check() { if (!isset($this->_check)) { $check_query = tep_db_query("SELECT configuration_value FROM " . TABLE_CONFIGURATION . " WHERE configuration_key = 'MODULE_SHIPPING_ITEM_MODEL_STATUS'"); $this->_check = tep_db_num_rows($check_query); } return $this->_check; }//ends check function 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 ('Enable Model Shipping', 'MODULE_SHIPPING_ITEM_MODEL_STATUS', 'True', 'Do you want to offer model shipping rates?', '6', '0', '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, use_function, set_function, date_added) VALUES ('Tax Class', 'MODULE_SHIPPING_ITEM_MODEL_TAX_CLASS', '0', 'Use the following tax class on the shipping fee.', '6', '0', 'tep_get_tax_class_title', 'tep_cfg_pull_down_tax_classes(', now())"); tep_db_query("INSERT INTO " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) VALUES ('Sort Order', 'MODULE_SHIPPING_ITEM_MODEL_SORT_ORDER' , '0', 'Sort Order of display.', '6', '0', now())"); for ($i = 1; $i <= $this->num_zones; $i++) { $default_countries = ''; if ($i == 1) { $default_countries = 'US'; } elseif ($i == 2) { $default_countries = 'CA'; } elseif ($i == 3) { $default_countries = 'AT,BE,GB,FR,DE,GL,IS,IE,IT,NO,NL,DK,PL,ES,SE,CH,FI,PT,IL,GR'; } elseif ($i == 4) { $default_countries = 'JP,AU,NZ,SG'; } elseif ($i == 5) { $default_countries = 'TW,CN,HK'; }//ends the if statments for default countires tep_db_query("INSERT INTO " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) VALUES ('Zone " . $i ." Countries', 'MODULE_SHIPPING_ITEM_MODEL_COUNTRIES_" . $i ."', '" . $default_countries . "', 'Comma seprtated list of two character ISO country codes that are part of zone " . $i . ".', '6', '0', now())"); }//ends the for loop }//ends the install function function remove() { tep_db_query("DELETE FROM " . TABLE_CONFIGURATION . " WHERE configuration_key in ('" . implode(" ', '", $this->keys()) . "')"); }//ends the remove function function keys() { $keys = array('MODULE_SHIPPING_ITEM_MODEL_STATUS', 'MODULE_SHIPPING_ITEM_MODEL_TAX_CLASS', 'MODULE_SHIPPING_ITEM_MODEL_SORT_ORDER'); for ($i=1; $i<=$this->num_zones; $i++) { $keys[] = 'MODULE_SHIPPING_ITEM_ZONES_COUNTRIES_' . $i; }//ends the for loop return $keys; }//ends the keys function }//ends the modlue ?> Edited October 6, 2005 by shaggy2dope2125 Quote Link to comment Share on other sites More sharing options...
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.