VirtueMart Forum

VirtueMart 1.1.x [ Old version - no longer supported ] => Shipping VM 1.1 => USPS (U.S. Postal Service) VM 1 => Topic started by: klattr1 on February 14, 2011, 04:56:11 AM

Title: USPS domestic military shipping *need conditional written
Post by: klattr1 on February 14, 2011, 04:56:11 AM
URL to reference: http://www.deatschwerks.com (http://www.deatschwerks.com)

Right now I have FedEx enabled for all domestic shipping and USPS enabled for all international shipping. I want that to continue to working the way it is.

But I would also like to be able to ship to military APO addresses (AA, AE, and AP). I've added those as "states" within the United States in VirtueMart and that part seems to work correctly.

The fix I need is for a conditional to be written so that USPS domestic options (Express or Parcel Post) only show up when a APO shipping address is requested.

Anyone willing to help with this? Right now I'm using lowmips's FedEx V5 module and the USPS V4 module.

Thanks.
Title: Re: USPS domestic military shipping *need conditional written
Post by: lowmips on February 14, 2011, 15:47:51 PM
I actually made a mod exactly for this purpose some time back.  It was based on the 4.0 version of Chaz's module.  Note the "state" declarations in the $apo_states array.  Modify that to fit your state abbreviations.  The code I added was this, in the "list_rates()" function at the top (just below the global declarations) :


$db =& new ps_DB;


/** Read current Configuration ***/

require_once(CLASSPATH ."shipping/".$this->classname.".cfg.php");

$q  = "SELECT * FROM `#__{vm}_user_info`, `#__{vm}_country` WHERE user_info_id='" . $d["ship_to_info_id"]."' AND ( country=country_2_code OR country=country_3_code)";

$db->query($q);

$db->next_record();





/*

* Modified to only show USPS rates if the user has an APO address

*

*/

$apo_states = array("AA","AE","AP");

$mystate = $db->f('state');


if (!in_array($mystate,$apo_states)) return false;