Beezer2005 Posted February 12, 2005 Share Posted February 12, 2005 Hi..I recently installed the regions shipping module from Jorge (billy the kid) and keep getting the follwing error...also below is what my regions.php looks like...ANY HELP would be greatly appreciated!! Thanks Parse error: parse error, unexpected '{' in /home/rubarts4/public_html/catalog/includes/modules/shipping/regions.php on line 197 <?php /* $Id: regions.php, v 4.0 2004/12/22 14:29:56 Jorge Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright © 2002 osCommerce Released under the GNU General Public License ----------------------------------------------------------------------------- REGIONS - Rates Based on State or Regions (group of States) module for osC 2.2-CVS (new checkout) This module allows you create shipping regions by dividing states of the USA (or other country) in different groups. Each group will then have it's own shipping price which you can based on price or weight. This module is perfect when for those of you need to charge different when shipping to different parts of the country. Features 1..Regions can be composed of US States or of any other country 2..Order weight or price can be used to calculate shipping price. 3..Any number of regions 4..Handling fee can be added. Jorge Set the number of regions you need with $this->regions = xx; Please note that any country / state that is not in one of the groups will not be able to checkout if this the only shipping you provide. However it will display a nice message saying so. Written by Jorge ([email protected]) */ class regions { var $code, $title, $description, $enabled, $regions; // class constructor function regions() { $this->code = 'regions'; $this->title = MODULE_SHIPPING_REGIONS_TEXT_TITLE; $this->description = MODULE_SHIPPING_REGIONS_TEXT_DESCRIPTION; $this->icon = ''; $this->tax_class = MODULE_SHIPPING_REGIONS_TAX_CLASS; $this->enabled = MODULE_SHIPPING_REGIONS_STATUS; $this->sort_order = MODULE_SHIPPING_REGIONS_SORT_ORDER; // CUSTOMIZE THIS SETTING FOR THE NUMBER OF States NEEDED $this->regions = 8; } // class methods function quote($method = '') { global $order, $shipping_weight, $cart, $total_count; if (MODULE_SHIPPING_REGIONS_MODE == 'price') { $order_total_price = $cart->show_total(); } if (MODULE_SHIPPING_REGIONS_MODE == 'weight') { $order_total_price = $shipping_weight; } if (MODULE_SHIPPING_REGIONS_MODE == 'per_item') { $order_total_price = $total_count; } if (MODULE_SHIPPING_REGIONS_MODE == 'percentage') { $order_total_price = $cart->show_total(); } $dest_state = $order->delivery['state']; $dest_country = $order->delivery['country']['title']; $dest_region = 0; $error = false; for ($i=1; $i<=$this->regions; $i++) { $regions_table = constant('MODULE_SHIPPING_REGIONS' . $i); $country_states_or_countries = split("[,]", $regions_table); if (in_array($dest_state, $country_states_or_countries)) { $dest_region = $i; break; } } if ($dest_region == 0) { for ($i=1; $i<=$this->regions; $i++) { $regions_table = constant('MODULE_SHIPPING_REGIONS' . $i); $country_states_or_countries = split("[,]", $regions_table); if (in_array($dest_country, $country_states_or_countries)) { $dest_region = $i; break; } } } if ($dest_region == 0) { $error = true; } else { $shipping = -1; $region_cost = constant('MODULE_SHIPPING_REGIONS_COST' . $i); $regions_table = split("[:,]" , $region_cost); if (MODULE_SHIPPING_REGIONS_MODE == 'price') { for ($i=0; $i<sizeof($regions_table); $i+=2) { if ($order_total_price <= $regions_table[$i]) { $shipping = $regions_table[$i+1]; $shipping_method = MODULE_SHIPPING_REGIONS_TEXT_WAY . ' ' . "$dest_state, $dest_country" . ' ' . MODULE_SHIPPING_REGIONS_TEXT_UNITS; break; } } } if (MODULE_SHIPPING_REGIONS_MODE == 'weight') { for ($i=0; $i<sizeof($regions_table); $i+=2) { if ($order_total_price <= $regions_table[$i]) { $shipping = $regions_table[$i+1]; $shipping_method = MODULE_SHIPPING_REGIONS_WEIGHT . ' ' . $shipping_weight . ' ' . MODULE_SHIPPING_REGIONS_WEIGHT_TEXT . ' ' . "$dest_state, $dest_country" . ' ' . MODULE_SHIPPING_REGIONS_TEXT_UNITS; break; } } } if (MODULE_SHIPPING_REGIONS_MODE == 'per_item') { for ($i=0; $i<sizeof($regions_table); $i+=2) { if ($order_total_price <= $regions_table[$i]) { $shipping = $regions_table[$i+1] * $order_total_price; $shipping_method = MODULE_SHIPPING_REGIONS_ITEMS . ' ' . $total_count . ' ' . MODULE_SHIPPING_REGIONS_ITEMS_TEXT . ' ' . "$dest_state, $dest_country" . ' ' . MODULE_SHIPPING_REGIONS_TEXT_UNITS; break; } } } if (MODULE_SHIPPING_REGIONS_MODE == 'percentage') { for ($i=0; $i<sizeof($regions_table); $i+=2) { if ($order_total_price <= $regions_table[$i]) { $shipping = ($regions_table[$i+1] / 100) * $order_total_price; $shipping_method = MODULE_SHIPPING_REGIONS_TEXT_WAY . ' ' . "$dest_state, $dest_country" . ' ' . MODULE_SHIPPING_REGIONS_TEXT_UNITS; break; } } } if ($shipping == -1) { $shipping_cost = 0; $shipping_method = MODULE_SHIPPING_REGIONS_UNDEFINED_RATE; } else { $shipping_cost = ($shipping + MODULE_SHIPPING_REGIONS_HANDLING + SHIPPING_HANDLING); } } $this->quotes = array('id' => $this->code, 'module' => MODULE_SHIPPING_REGIONS_TEXT_TITLE, 'methods' => array(array('id' => $this->code, 'title' => $shipping_method, 'cost' => $shipping_cost))); if ($this->tax_class > 0) { $this->quotes['tax'] = tep_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']); } if (tep_not_null($this->icon)) $this->quotes['icon'] = tep_image($this->icon, $this->title); if ($error == true) $this->quotes['error'] = MODULE_SHIPPING_REGIONS_INVALID_ZONE; return $this->quotes; } function check() { if (!isset($this->_check)) { $check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_REGIONS_STATUS'"); $this->_check = tep_db_num_rows($check_query); } return $this->_check; } function install() { tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) VALUES ('Enable US Regions Method', 'MODULE_SHIPPING_REGIONS_STATUS', '1', 'Do you want to offer Regions rate shipping?', '6', '0', 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_REGIONS_SORT_ORDER', '1', 'Sort order of display.', '6', '1', 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_REGIONS_TAX_CLASS', '1', 'Use the following tax class on the shipping fee.', '6', '2', '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 ('Handling Fee', 'MODULE_SHIPPING_REGIONS_HANDLING', '0.00', 'Handling Fee for this shipping method', '6', '3', 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 ('Mode', 'MODULE_SHIPPING_REGIONS_MODE', 'price', 'Is the shipping table based on total weight, total amount of order, number of itmes, or a percentage of the total price.', '6', '4', 'tep_cfg_select_option(array(\'weight\', \'price\', \'per_item\', \'percentage\'), ', now())"); for ($i = 1; $i <= $this->regions; $i++) { $default_countries = ''; if ($i == 1) { $default_states_or_countries = 'California'; $default_prices = '24.99:8.50,499.99:15%,1000:6%'; } if ($i == 2) { $default_states_or_countries = 'Arizona,Utah,Nevada'; $default_prices = '24.99:8.50,499.99:17%,1000:7%'; } if ($i == 3) { $default_states_or_countries = 'New Mexico,Colorada,Wyoming,Idaho,Oregon,Washington'; $default_prices = '24.99:8.50,499.99:19%,1000:8%'; } if ($i == 4 { $default_states_or_countries = 'Texas,Oklahoma,Kansas,Nebraska,South Dakota,North Dakota,Montana'; $default_prices = '24.99:8.50,499.99:21%,1000:9%'; } if ($i == 5 { $default_states_or_countries = 'Louisiana,Missouri,Alabama,Arkansas,Mississippi,Illinois,Indiana,Iowa,Wiscon sin,Minnesota'; $default_prices = '24.99:8.50,499.99:21%:23%,1000:10%'; } if ($i == 6 { $default_states_or_countries = 'Florida,Georgia,South Carolina,Tennesee,North Carolina,Kentucky,Virginia,West Virginia,Maryland,Ohio,Deleware,District Of Columbia,Pennsylvania,Michigan,New Jersey,New York,Rhode Island,Connecticut,Massachusettes,New Hampshire,Vermont,Maine'; $default_prices = '24.99:8.50,499.99:215:25%,1000:11%'; } if ($i == 7 { $default_states_or_countries = 'Canada'; $default_prices = '24.99:8.50,1000:20%'; } if ($i == 8 { $default_states_or_countries = 'Alaska,Virgin Islands,Guam,Puerto Rico,Hawaii'; $default_prices = '24.99:14.50,1000:50%'; } tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Region " . $i ." States/Countries', 'MODULE_SHIPPING_REGIONS" . $i ."', '" . $default_states_or_countries . "', 'Comma separated list of States and/or Countries', '6', '0', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Region " . $i ." Shipping Table', 'MODULE_SHIPPING_REGIONS_COST" . $i ."', '" . $default_prices . "' , '(weight/price/# of items/)<b>:</b>(shipping cost/percentage)', '6', '0', 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 keys() { $keys = array('MODULE_SHIPPING_REGIONS_STATUS', 'MODULE_SHIPPING_REGIONS_SORT_ORDER', 'MODULE_SHIPPING_REGIONS_HANDLING', 'MODULE_SHIPPING_REGIONS_MODE', 'MODULE_SHIPPING_REGIONS_TAX_CLASS'); for ($i=1; $i<=$this->regions; $i++) { $keys[] = 'MODULE_SHIPPING_REGIONS' . $i; $keys[] = 'MODULE_SHIPPING_REGIONS_COST' . $i; } return $keys; } } ?> 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.