ChronoXP Posted December 17, 2003 Share Posted December 17, 2003 I'm having a hard time trying to configure the shipping module(s). I only require domestic shipping, so I've removed all countries except United Kingdom. How do I go about making shipping calculations based on UK shipping zones/regions? Zone 1: UK Mainland (England, Wales, parts of Scotland) Zone 2: Scottish Highlands and Islands Zone 3: Northern Ireland, Isle of Man, Isles of Scilly Zone 4: Channel Islands I tried a somewhat less than elegant solution by defining the above zones as Countries and using U1, U2, etc. as ISO code, and increasing zones from 1 to 4 in zones.php. Account Creation works fine like this, but Checkout displays "Shipping to U1" which is ugly. Someone suggested I make several zones.php (zone1.php, zone2.php, etc.), but I don't really understand why :unsure: I'd really appreciate some help :) Link to comment Share on other sites More sharing options...
ChrisHoward Posted December 17, 2003 Share Posted December 17, 2003 Why dont you just use a multiple flat shipping rates contrib this should aloow tyou to add amultiple amount of shipping areas to the site and the customer selects the area in which they fall into. The mulitple flat shipping rates conrtib is in the contrib section under shipping i wrote a new version. If you have any probs e-mail me at [email protected] Link to comment Share on other sites More sharing options...
ChronoXP Posted December 17, 2003 Author Share Posted December 17, 2003 Thanks for your suggestion, Chris; I'll give it a try this afternoon :D Link to comment Share on other sites More sharing options...
ChronoXP Posted December 17, 2003 Author Share Posted December 17, 2003 Oops, perhaps I should've mentioned the shipping costs will be based on weight :wacko: :( Link to comment Share on other sites More sharing options...
ChronoXP Posted December 19, 2003 Author Share Posted December 19, 2003 Um :unsure: I still don't get it - to me it seems osCommerce and the default shipping modules can't do what I want? I can't find any contribs that'll do it either :( And I still can't figure out an "elegant" way of informing osCommerce that the UK is comprised of 4 or 5 shipping zones, rather than just being a single entity. How on earth can oSCommerce be set up to recognise UK Mainland, Highlands, Channel Islands, Northern Island as seperate shipping zones, other than entering each as a country with a made up ISO code (which sort of semi-works, but isn't pretty)? :blink: Link to comment Share on other sites More sharing options...
geenygreat Posted December 19, 2003 Share Posted December 19, 2003 You may try following: Replace the following in /includes/modules/shipping/zones.php: 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_ZONES_COUNTRIES_' . $i); $country_zones = split("[,]", $countries_table); if (in_array($dest_country, $country_zones)) { $dest_zone = $i; break; } } if ($dest_zone == 0) { $error = true; } else { $shipping = -1; $zones_cost = constant('MODULE_SHIPPING_ZONES_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_ZONES_TEXT_WAY . ' ' . $dest_country . ' : ' . $shipping_weight . ' ' . MODULE_SHIPPING_ZONES_TEXT_UNITS; break; } } if ($shipping == -1) { $shipping_cost = 0; $shipping_method = MODULE_SHIPPING_ZONES_UNDEFINED_RATE; } else { $shipping_cost = ($shipping * $shipping_num_boxes) + constant('MODULE_SHIPPING_ZONES_HANDLING_' . $dest_zone); } } $this->quotes = array('id' => $this->code, 'module' => MODULE_SHIPPING_ZONES_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_ZONES_INVALID_ZONE; return $this->quotes; } With: function quote($method = '') { global $order, $shipping_weight, $shipping_num_boxes; $dest_country = $order->delivery['country']['id']; $dest_zone_id = $order->delivery['zone_id']; $dest_zone_code = tep_get_zone_code($dest_country,$dest_zone_id) $dest_zone = 0; $error = false; for ($i=1; $i<=$this->num_zones; $i++) { $countries_table = constant('MODULE_SHIPPING_ZONES_COUNTRIES_' . $i); $country_zones = split("[,]", $countries_table); if (in_array($dest_zone_code, $country_zones)) { $dest_zone = $i; break; } } if ($dest_zone == 0) { $error = true; } else { $shipping = -1; $zones_cost = constant('MODULE_SHIPPING_ZONES_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_ZONES_TEXT_WAY . ' ' . $dest_zone_code . ' : ' . $shipping_weight . ' ' . MODULE_SHIPPING_ZONES_TEXT_UNITS; break; } } if ($shipping == -1) { $shipping_cost = 0; $shipping_method = MODULE_SHIPPING_ZONES_UNDEFINED_RATE; } else { $shipping_cost = ($shipping * $shipping_num_boxes) + constant('MODULE_SHIPPING_ZONES_HANDLING_' . $dest_zone); } } $this->quotes = array('id' => $this->code, 'module' => MODULE_SHIPPING_ZONES_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_ZONES_INVALID_ZONE; return $this->quotes; } Let me know if it works or any error? Link to comment Share on other sites More sharing options...
ChronoXP Posted December 19, 2003 Author Share Posted December 19, 2003 Parse error: parse error in /home/chronoxp/public_html/test/includes/modules/shipping/zones.php on line 119 That's when going into Admin/Modules/Shipping :unsure: Link to comment Share on other sites More sharing options...
geenygreat Posted December 19, 2003 Share Posted December 19, 2003 Look for the following line in the above code, a semi colon is missing at the end. $dest_zone_code = tep_get_zone_code($dest_country,$dest_zone_id); Link to comment Share on other sites More sharing options...
ChronoXP Posted December 19, 2003 Author Share Posted December 19, 2003 That fixes the Admin error, however, when going to checkout, this happens: Warning: Missing argument 3 for tep_get_zone_code() in /home/chronoxp/public_html/test/includes/functions/general.php on line 242 This is currently the only shipping method available to use on this order. Zone Rates No shipping available to the selected country I'm certain my botched attempt at splitting the UK into 4 shipping destinations is the root of all problems? Link to comment Share on other sites More sharing options...
geenygreat Posted December 19, 2003 Share Posted December 19, 2003 hmmm.... Change the following line in the above code: $dest_zone_code = tep_get_zone_code($dest_country,$dest_zone_id) To: $dest_zone_code = tep_get_zone_shipping_code($dest_country,$dest_zone_id) Add the followng function in admin/includes/general.php: function tep_get_zone_shipping_code($country, $zone) { $state_prov_query = tep_db_query("select zone_code from " . TABLE_ZONES . " where zone_country_id = '" . (int)$country . "' and zone_id = '" . (int)$zone . "'"); $state_prov_values = tep_db_fetch_array($state_prov_query); $state_prov_code = $state_prov_values['zone_code']; return $state_prov_code; } Link to comment Share on other sites More sharing options...
ChronoXP Posted December 19, 2003 Author Share Posted December 19, 2003 Add the followng function in admin/includes/general.php: function tep_get_zone_shipping_code($country, $zone) { ? ? $state_prov_query = tep_db_query("select zone_code from " . TABLE_ZONES . " where zone_country_id = '" . (int)$country . "' and zone_id = '" . (int)$zone . "'"); ? ? ? $state_prov_values = tep_db_fetch_array($state_prov_query); ? ? ? $state_prov_code = $state_prov_values['zone_code']; ? ? ? ? return $state_prov_code; ? } Um, I don't have a general.php in admin/includes :wacko: Link to comment Share on other sites More sharing options...
geenygreat Posted December 19, 2003 Share Posted December 19, 2003 Ooops. it is in admin/includes/functions Link to comment Share on other sites More sharing options...
ChronoXP Posted December 19, 2003 Author Share Posted December 19, 2003 I get this on checkout now: Fatal error: Call to undefined function: tep_get_zone_shipping_code() in /home/chronoxp/public_html/test/includes/modules/shipping/zones.php on line 118 Link to comment Share on other sites More sharing options...
geenygreat Posted December 19, 2003 Share Posted December 19, 2003 Add tep_get_zone_shipping_code() defined above in /test/includes/functions/general.php Link to comment Share on other sites More sharing options...
ChronoXP Posted December 19, 2003 Author Share Posted December 19, 2003 That's fixed the errors... but checkout says "No shipping available to the selected country". Is it because of the deranged way I've gone about things: Admin / Locations and Taxes / Countries UK (Mainland) U1(2) UK1(3) UK (Scottish Highands) U2(2) UK2(3) UK (Northern Ireland) U3(2) UK3(3) UK (Channel Islands) U4(2) UK4(3) Admin / Locations and Taxes / Zones no zones at all Admin / Modules / Shipping Zone Rates Zone 1: U1 Zone 2: U2 Zone 3: U3 Zone 4: U4 This is all wrong :unsure: Link to comment Share on other sites More sharing options...
geenygreat Posted December 19, 2003 Share Posted December 19, 2003 I have modified the module to work for 1 country and zones within it. Set 1 country in Admin / Locations and Taxes / Countries: United Kingdom GB GBR Define zones for United Kingdom in Admin / Locations and Taxes / Zones as: UK (Mainland) U1 UK (Scottish Highands) U2 UK (Northern Ireland) U3 UK (Channel Islands) U4 Define zone rates for U1, U2, U3, U4. Hope it works! Link to comment Share on other sites More sharing options...
ChronoXP Posted December 19, 2003 Author Share Posted December 19, 2003 Nope, still no shipping method on checkout :( And doing it that way makes Account Create / County only allow one of the four zones, rather than Stafforshire or whatever (I haven't imported the UK Counties into the database?). It's like there needs to be another field in Account Create where people have to enter the region they're in, or the ISO code system for countries/zones needs enhancing so meaningful information can be used? How have other UK stores gotten around this? /deflated Link to comment Share on other sites More sharing options...
geenygreat Posted December 19, 2003 Share Posted December 19, 2003 Lee, It looks i can not get the way you need it. Well, I will work more on this and try on my test store myself, and if get any success, i will post it. Link to comment Share on other sites More sharing options...
ChronoXP Posted December 20, 2003 Author Share Posted December 20, 2003 I've given up - there just doesn't seem any logical way of doing this, and short of me becoming a PHP and MySQL guru over the weekend, it's becoming clear that I'm not destined to get an osCommerce store online. Serves me right for trying to avoid spending money on Actinic <_< Link to comment Share on other sites More sharing options...
ChronoXP Posted December 20, 2003 Author Share Posted December 20, 2003 That said, might this work: Import UK counties into database. Work out which counties have increased shipping costs. Setup zone rates to reflect this, and have the added benefit of maintaining the proper(?) ISO codes? Geography isn't my strong point, but it's probably a bit stronger than my PHP skills :unsure: Or will this fail because all the counties are zones linked to Country UK - if zone 1 is UK, then all the county zones are covered, or will setting zone 2, zone 3 to the appropriate counties overide the Zone 1 setting? Knowing osCommerce, it'll display both zone 1 and zone X shipping for those counties :blink: Link to comment Share on other sites More sharing options...
Dex Posted December 30, 2003 Share Posted December 30, 2003 I think this open source might solve your problem, http://www.cubecart.com I like the way it provide a full country list and allows you to define for each country: No Delivery, International, National for No Delivery, any customer's delivery address from the No Delivery Zone will not be allowed. I think you got to play with the product option settings to get to the right price for delivery, i can't figure out that part. But i prefer osCommerce for a lot of other reasons. I have similar problem. I also sell products in 1 or 2 countries and do not want to entertain orders beyond that. else i will have a lot of orders that i can fullfiul. Can't figure out with osCommerce as well. Hope some one develop a module for that. It will be great! Thanks Dex Link to comment Share on other sites More sharing options...
brooky Posted January 19, 2004 Share Posted January 19, 2004 Hi, Yes I wrote CubeCart.... although competing with the master OSCommerce is not easy. :) I think you are right OSCommerce is truly wonderful especially the www.aaopen.com version I have not yet to installed and tried. p.s. I found this post from my web stats. I hope you get it sorted, I am English and www.cubecart.com was written prodiminently with British business knowledge in mind. Only think is CubeCart as yet doesn't have much info concerning stage of order and exactly how order processing works. I think this is an EU law now. Anyhow I'm rambling on and its late... good luck!! :D Link to comment Share on other sites More sharing options...
adiwillow Posted May 9, 2004 Share Posted May 9, 2004 There is a UK zones contrib that lists all the counties for the UK.. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.