salim Posted March 10, 2007 Share Posted March 10, 2007 Just something to share and think might be useful for others. I searched for information on how to disable international shipping address. I was looking for very minor touch up in the code in USPS shipping module to achieve this goal. I do find some suggestions such as installing USPSMethod, delete countries from the database and etc. Those are great advices but are overkill for my purpose. Eventually, I decide to dive into the code myself. After reading usps.php, I do come up with a minor change that will serve my purpose. With these change, you are preventing shipping option from being displayed during checkout process if the destination address is non domestic, ie origin and destination is not the same country. As usual, I'll not responsible for breaking anything at your site. Always backup a copy of the file before making change is advisable. Open up this file catalog/includes/modules/shipping/usps.php Look for class method of quote(), about line 80, you will see these lines. $shipping_ounces = round(16 * ($shipping_weight - floor($shipping_weight))); $this->_setWeight($shipping_pounds, $shipping_ounces); if (is_array($uspsQuote)) { if (isset($uspsQuote['error'])) { $this->quotes = array('module' => $this->title, 'error' => $uspsQuote['error']); } else { . . . Add this block of if statement before if(is_array($uspsQuote)){ if($order->delivery['country']['id'] == SHIPPING_ORIGIN_COUNTRY){ $uspsQuote = $this->_getQuote(); } else { $uspsQuote = array("error" => "<font color='red'><b>Sorry. No international shipping is permitted at this moment via USPS.</b></font>"); } The whole new code will read this. $shipping_ounces = round(16 * ($shipping_weight - floor($shipping_weight))); $this->_setWeight($shipping_pounds, $shipping_ounces); //New ode here if($order->delivery['country']['id'] == SHIPPING_ORIGIN_COUNTRY){ $uspsQuote = $this->_getQuote(); } else { $uspsQuote = array("error" => "<font color='red'><b>Sorry. No international shipping is permitted at this moment via USPS.</b></font>"); } //End new code if (is_array($uspsQuote)) { if (isset($uspsQuote['error'])) { $this->quotes = array('module' => $this->title, 'error' => $uspsQuote['error']); } else { Of course, you can change the error message the way you like. I also did the similar customization for UPS. Email me if you are interested in it. It is slightly different in UPS but not too much of change. Hope this will be helpful for others. Please feel free to comment, correction, improvement if there is any you come up with. Cheer. salim http://www.techkool.com Link to comment Share on other sites More sharing options...
vasttech Posted March 11, 2007 Share Posted March 11, 2007 You can also just set the various shipping methods to show in a particular zone through the admin section. For instance on the USPS method, just set the zone to US and whenever someone outside the US goes to checkout USPS won't be there. osCommerce Knowledge Base osCommerce Documentation Contributions Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.