[HACK] Shipping Address to use abbrev for State (USA only)

Modules, Add-ons and custom code that's more than just a quick hack or Mod.
Post Reply
Martin
Site Admin
Site Admin
Posts: 1854
Joined: Wed Jun 17, 2009 6:30 pm
Location: South Yorkshire UK
Contact:

[HACK] Shipping Address to use abbrev for State (USA only)

Post by Martin »

This hack is very basic and just provides the shipping address, state information in standard abbreviated format as part of the zip code.

Known compatibility: ISC 5.0.5

Open: /admin/includes/classes/class.shipments.php

Find:

Code: Select all

		$GLOBALS['BillingAddress'] = ISC_ADMIN_ORDERS::BuildOrderAddressDetails($addressDetails, false);
After, Add:

Code: Select all

		// MOD Abbrev USA State - Shipping only.
		/*
		 * Generates 2 letter state code for USA orders and append to zip code
		 * Also removes the state full text if valid state found.
		 * 
		 */
		
		if($shipmentDetails[$addressColumnPrefix.'shipcountryid'] == 226) {
			
			// Get the abbreviation
			$query = "SELECT stateabbrv FROM [|PREFIX|]country_states WHERE stateid = ". $shipmentDetails[$addressColumnPrefix.'shipstateid'];
			$query .= $GLOBALS['ISC_CLASS_DB']->AddLimit(0, 1);
			$result = $GLOBALS['ISC_CLASS_DB']->Query($query);
			if($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
				$shipmentDetails[$addressColumnPrefix.'shipzip'] = $row['stateabbrv']." ".$shipmentDetails[$addressColumnPrefix.'shipzip'];
				$shipmentDetails[$addressColumnPrefix.'shipstate'] = '';
			} 
		}
		// END MOD.
Note: this hack depends on the USA being set as country with countryid of 226... If your country data uses a different value (because you've hacked the data or similar) it will not work properly.
Post Reply