Enzo_UK Posted November 4, 2016 Share Posted November 4, 2016 (edited) I am using a few different shipping methods together (table rates, zone rates, and a massively modified zone rates) all in conjunction with ship in cart. I use my 'zone rates' for customers outside the UK, as the rates for within the UK are a combination of 'table rates' and my 'modified zone rates'. What I want to do is totally disable the 'zone rates' if the customer is from the UK, rather than having it still show up on the ship in cart and on the shipping page with an error message. I kind of know how I want it to work, but just cant get my head round the coding... // class constructor function zones() { $this->code = 'zones'; $this->title = MODULE_SHIPPING_ZONES_TEXT_TITLE; $this->description = MODULE_SHIPPING_ZONES_TEXT_DESCRIPTION; $this->sort_order = MODULE_SHIPPING_ZONES_SORT_ORDER; $this->icon = ''; $this->tax_class = MODULE_SHIPPING_ZONES_TAX_CLASS; $this->enabled = ((MODULE_SHIPPING_ZONES_STATUS == 'True') ? true : false); // CUSTOMIZE THIS SETTING FOR THE NUMBER OF ZONES NEEDED $this->num_zones = 4; } I basically want something along the lines of... if ($order->delivery['iso_code_2'] == UK) {$this->enabled = false;} I don't even know if that's going to be the right way to do it, or how to add it into the existing code without messing it all up. Any help is greatly appreciated. Edited November 4, 2016 by Enzo_UK Quote Link to comment Share on other sites More sharing options...
♥kymation Posted November 5, 2016 Share Posted November 5, 2016 Remove all of your modules and use the MZMT Addon for the whole thing. No modifications needed, just set up your zones and tables. Regards Jim Quote See my profile for a list of my addons and ways to get support. Link to comment Share on other sites More sharing options...
Enzo_UK Posted November 5, 2016 Author Share Posted November 5, 2016 I don't think MZMT will do what I need... as I have kind of made my own module that takes the customers UK postcode however its supplied, with space or without space, lowercase of capitals (e.g. ab123cd, ab12 3cd, AB123CD, AB12 3CD) and splits it and have a table that assigns the first part of the UK postcode to a zone. Quote Link to comment Share on other sites More sharing options...
♥kymation Posted November 5, 2016 Share Posted November 5, 2016 I'm not aware of any stock shipping module that will meet that last requirement, so you're back to modifying a stock module. Sorry I couldn't help. Regards Jim Quote See my profile for a list of my addons and ways to get support. Link to comment Share on other sites More sharing options...
Enzo_UK Posted November 5, 2016 Author Share Posted November 5, 2016 Had a little think, and is there some way I can use the bit from in Flat rates to do what I want to do in my Zone rates? As in Flat rates there is the option of only aplying it to only one zone... so would make sense this can be reworked to exclude one zone in Zone rates. $this->enabled = ((MODULE_SHIPPING_FLAT_STATUS == 'True') ? true : false); if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_FLAT_ZONE > 0) ) { $check_flag = false; $check_query = tep_db_query("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_SHIPPING_FLAT_ZONE . "' and zone_country_id = '" . $order->delivery['country']['id'] . "' order by zone_id"); while ($check = tep_db_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; } } Quote Link to comment Share on other sites More sharing options...
♥kymation Posted November 5, 2016 Share Posted November 5, 2016 The code that you posted in your initial post is close to what you need. Something like this: if ($order->delivery['iso_code_2'] == 'UK') { $this->enabled = false; } Add that to the end of the class constructor and it should do what you want. Assuming that the ISO code really is UK -- I didn't check. Regards Jim Quote See my profile for a list of my addons and ways to get support. Link to comment Share on other sites More sharing options...
Enzo_UK Posted November 6, 2016 Author Share Posted November 6, 2016 (edited) if ($this->enabled == true) { global $order; if ($order->delivery['country']['iso_code_2'] == 'GB') { $this->enabled = false; } } I managed to get there in the end, thanks for telling me I was along the right lines, which made me stick with it. Works as intended now, many thanks. Edited November 6, 2016 by Enzo_UK Quote Link to comment Share on other sites More sharing options...
Enzo_UK Posted November 6, 2016 Author Share Posted November 6, 2016 (edited) Slight glitch... it worked fine when a customer is not logged in and your just switching between countries using the drop down menu in the ship in cart. Once a customer was logged in you no longer have the countries drop down, and just uses the info from the customers address book, so have had to change it to using country_id instead. if ($this->enabled == true) { global $order; if ($order->delivery['country_id'] == '// YOUR COUNTRY ID HERE') { $this->enabled = false; } } Edited November 6, 2016 by Enzo_UK 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.