Dr_killer_UK Posted February 10, 2009 Posted February 10, 2009 I have tried for days searching and messing with the airmail but will not work correctly for me! I have a UK store and am using Royal Mail. I have 1st class, 1st recorded, 2nd, 2nd recorded, standard parcel and special delivery all sorted and working. The only problem i can't seem to fix is airmail showing up when united kingdom is selected so you see a list of 1st class and the others then airmail at the bottom which shouldn't be showing up unless another none united kingdom country is selected. I do not have GB in the list of country zones for airmail shipping so not sure why it shows up for GB (United kingdom) It also doesn't even calculate the postage correctly to. Here is my airmail.php */ class airmail { var $code, $title, $description, $enabled, $num_zones; // class constructor function airmail() { $this->code = 'airmail'; $this->title = MODULE_SHIPPING_AIRMAIL_TEXT_TITLE; $this->description = MODULE_SHIPPING_AIRMAIL_TEXT_DESCRIPTION; $this->sort_order = MODULE_SHIPPING_AIRMAIL_SORT_ORDER; $this->icon = DIR_WS_ICONS . 'shipping_airmail.gif'; // upload icon to catalog/images/icon directory $this->tax_class = MODULE_SHIPPING_AIRMAIL_TAX_CLASS; $this->enabled = ((MODULE_SHIPPING_AIRMAIL_STATUS == 'True') ? true : false); // CUSTOMIZE THIS SETTING FOR THE NUMBER OF ZONES NEEDED $this->num_zones = 2; } // class methods function quote($method = '') { global $order, $shipping_weight, $shipping_num_boxes; $dest_country = $order->delivery['country']['iso_code_2']; $dest_zone = 0; $error = false; for ($i=1; $i<=$this->num_zones; $i++) { $countries_table = constant('MODULE_SHIPPING_AIRMAIL_COUNTRIES_' . $i); $country_zones = split("[,]", $countries_table); if (in_array($dest_country, $country_zones)) { $dest_zone = $i; break; } } // elari - Added to select default country if not in listing if ($dest_zone == 0) { $dest_zone = $this->num_zones; // the zone is the lastest zone avalaible } // elari - Added to select default country if not in listing if ($dest_zone == 0) { $error = true; // this can no more achieve since by default the value is set to the max number of zones } else { $shipping = -1; $zones_cost = constant('MODULE_SHIPPING_AIRMAIL_COST_' . $dest_zone); $zones_table = split("[:,]" , $zones_cost); $size = sizeof($zones_table); for ($i=0; $i<$size; $i+=2) { if ($shipping_weight <= $zones_table[$i]) { $shipping = $zones_table[$i+1]; $shipping_method = MODULE_SHIPPING_AIRMAIL_TEXT_WAY . ' ' . $order->delivery['country']['title'] . ': '; if ($shipping_num_boxes > 1) { $shipping_method .= $shipping_num_boxes . 'x '; } $shipping_method .= $shipping_weight . ' ' . MODULE_SHIPPING_AIRMAIL_TEXT_UNITS; break; } } if ($shipping == -1) { $shipping_cost = 0; $shipping_method = MODULE_SHIPPING_AIRMAIL_UNDEFINED_RATE; } else { $shipping_cost = ($shipping * $shipping_num_boxes) + constant('MODULE_SHIPPING_AIRMAIL_HANDLING_' . $dest_zone); } } $this->quotes = array('id' => $this->code, 'module' => MODULE_SHIPPING_AIRMAIL_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_AIRMAIL_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_AIRMAIL_STATUS'"); $this->_check = tep_db_num_rows($check_query); } return $this->_check; } // elari - Added to select default country if not in listing 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 Zones Method', 'MODULE_SHIPPING_AIRMAIL_STATUS', 'True', 'Do you want to offer zone rate shipping?', '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_AIRMAIL_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_AIRMAIL_SORT_ORDER', '9', 'Sort order of display.', '6', '0', now())"); for ($i = 1; $i <= $this->num_zones; $i++) { $default_countries = ''; if ($i == 1) { $default_countries = 'AL,AD,AM,AT,AZ,BY,BE,BA,BG,HR,CY,CZ,DK,EE,FO,FI,FR,GE,DE,GI,GR,GL,HU,IS,IE,I T,KZ,KG,LV,LI,LT,LU,MK,MT,MD,MC,NL,NO,PL,PT,RO,RU,SM,SK,SI,ES,SE,CH,TJ,TR,TM,UA,U Z,VA'; $shipping_table = '.1:1.24,.12:1.36,.14:1.50,.16:1.63,.18:1.77.2:1.90,.22:2.03,.24:2.15,.26:2.2 8,.28:2.39,.3:2.51,.4:3.06,.5:3.61,.6:4.11,.7:4.61,.8:5.11,.9:5.61,1:6.11,1.1:6.6 1,1.2:7.11,1.3:7.61,1.4:8.11,1.5:8.61,1.6:9.11,1.7:9.61,1.8:10.11,1.9:10.61,2:11. 11,50:199'; } if ($i == 2) { $default_countries = 'US,CA'; // this must be the lastest zone $shipping_table = '.1:1.64,.12:1.87,.14:2.10,.16:2.33,.18:2.56.2:2.80,.22:3.01,.24:3.22,.26:3.4 3,.28:3.65,.3:3.87,.4:4.97,.5:6.07,.6:7.07,.7:8.07,.8:9.07,.9:10.07,1:11.07,1.1:1 2.07,1.2:13.07,1.3:14.07,1.4:15.07,1.5:16.07,1.6:17.07,1.7:18.07,1.8:19.07,1.9:20 .07,2:21.07,9:199'; } 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_AIRMAIL_COUNTRIES_" . $i ."', '" . $default_countries . "', 'Comma separated list of two character ISO country codes that are part of Zone " . $i . ".', '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 ('Zone " . $i ." Shipping Table', 'MODULE_SHIPPING_AIRMAIL_COST_" . $i ."', '" . $shipping_table . "', 'Shipping rates to Zone " . $i . " destinations based on a group of maximum order weights. Example: 3:8.50,7:10.50,... Weights less than or equal to 3 would cost 8.50 for Zone " . $i . " destinations.', '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 ('Zone " . $i ." Handling Fee', 'MODULE_SHIPPING_AIRMAIL_HANDLING_" . $i ."', '0', 'If you want to add extra costs to customers for jiffy bags etc, the cost can be entered below (eg enter 1.50 for a value of £1.50)', '6', '0', now())"); } } // elari - Added to select default country if not in listing function remove() { tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')"); } function keys() { $keys = array('MODULE_SHIPPING_AIRMAIL_STATUS', 'MODULE_SHIPPING_AIRMAIL_TAX_CLASS', 'MODULE_SHIPPING_AIRMAIL_SORT_ORDER'); for ($i=1; $i<=$this->num_zones; $i++) { $keys[] = 'MODULE_SHIPPING_AIRMAIL_COUNTRIES_' . $i; $keys[] = 'MODULE_SHIPPING_AIRMAIL_COST_' . $i; $keys[] = 'MODULE_SHIPPING_AIRMAIL_HANDLING_' . $i; } return $keys; } } ?> Quote
Dr_killer_UK Posted February 11, 2009 Author Posted February 11, 2009 I found the problem thanks to another member passing on his airmail.php to me. The one ever one downloads (or at least the one i did) is missing this line to where you select the country to not show airmail for. if ($order->delivery['country']['iso_code_2'] == 'GB') { $this->enabled = false; So the 1st part of code should look like this // class constructor function airmail() { global $order; $this->code = 'airmail'; $this->title = MODULE_SHIPPING_AIRMAIL_TEXT_TITLE; $this->description = MODULE_SHIPPING_AIRMAIL_TEXT_DESCRIPTION; $this->sort_order = MODULE_SHIPPING_AIRMAIL_SORT_ORDER; $this->icon = DIR_WS_ICONS . 'shipping_airmail.gif'; // upload icon to catalog/images/icon directory $this->tax_class = MODULE_SHIPPING_AIRMAIL_TAX_CLASS; $this->enabled = ((MODULE_SHIPPING_AIRMAIL_STATUS == 'True') ? true : false); if ($order->delivery['country']['iso_code_2'] == 'GB') { $this->enabled = false;[/b][/b] } // CUSTOMIZE THIS SETTING FOR THE NUMBER OF ZONES NEEDED $this->num_zones = 2; } Quote
Dr_killer_UK Posted February 11, 2009 Author Posted February 11, 2009 Ok airmial now not showing for UK orders but now i'm stuck with 22p for shipping to any zone at any weight and there isn't even 22p in the list of prices!! Here sit he zones and prices from my airmail.php NOT sure if i'm missing some thing simple or what. if ($i == 1) { $default_countries = 'AL,AD,AM,AT,AZ,BY,BE,BA,BG,HR,CY,CZ,DK,EE,FO,FI,FR,GE,DE,GI,GR,GL,HU,IS,IE,I T,KZ,KG,LV,LI,LT,LU,MK,MT,MD,MC,NL,NO,PL,PT,RO,RU,SM,SK,SI,ES,SE,CH,TJ,TR,TM,UA,U Z,VA'; //Airmail Rates for Europe at April 2007: Small packets to 2KG and printed Papers to 10KG (2 packets) $shipping_table = '.1:1.24,.12:1.36,.14:1.50,.16:1.63,.18:1.77.2:1.90,.22:2.03,.24:2.15,.26:2.2 8,.28:2.39,.3:2.51,.4:3.06,.5:3.61,.6:4.11,.7:4.61,.8:5.11,.9:5.61,1:6.11,1.1:6.6 1,1.2:7.11,1.3:7.61,1.4:8.11,1.5:8.61,1.6:9.11,1.7:9.61,1.8:10.11,1.9:10.61,2:11. 11,50:199'; } if ($i == 2) { $default_countries = 'All Others'; // this must be the lastest zone // Airmail Rates for Rest of World at April 2007: Small packets to 2KG and printed Papers to 10KG (2 packets) $shipping_table = '.1:1.64,.12:1.87,.14:2.10,.16:2.33,.18:2.56.2:2.80,.22:3.01,.24:3.22,.26:3.4 3,.28:3.65,.3:3.87,.4:4.97,.5:6.07,.6:7.07,.7:8.07,.8:9.07,.9:10.07,1:11.07,1.1:1 2.07,1.2:13.07,1.3:14.07,1.4:15.07,1.5:16.07,1.6:17.07,1.7:18.07,1.8:19.07,1.9:20 .07,2:21.07,9:199'; } Quote
Dr_killer_UK Posted February 12, 2009 Author Posted February 12, 2009 Got that fixed now to. I had a , missing in 1 part of the shipping table. Its so hard to tell and look through them all one after the other so if you get a simular problem (showing wrong cost or some strange cost) then just check your cost table. 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.