[interchange-cvs] interchange - jon modified dist/usertag/ups_query.tag

interchange-core@interchange.redhat.com interchange-core@interchange.redhat.com
Thu Jan 24 00:43:01 2002


User:      jon
Date:      2002-01-24 05:42:07 GMT
Modified:  dist/usertag ups_query.tag
Log:
User-friendliness enhancement:

Only pass on 5-digit base ZIP code in U.S., since UPS rejects ZIP+4.

Thanks to Bill Carr <bill@worldwideimpact.com> for pointing out this
requirement in Business::UPS docs.

Revision  Changes    Path
2.2       +7 -0      interchange/dist/usertag/ups_query.tag


rev 2.2, prev_rev 2.1
Index: ups_query.tag
===================================================================
RCS file: /var/cvs/interchange/dist/usertag/ups_query.tag,v
retrieving revision 2.1
retrieving revision 2.2
diff -u -u -r2.1 -r2.2
--- ups_query.tag	5 Sep 2001 15:10:08 -0000	2.1
+++ ups_query.tag	24 Jan 2002 05:42:07 -0000	2.2
@@ -8,17 +8,24 @@
 			import Business::UPS;
 		};
 	};
+
 	$origin		= $::Variable->{UPS_ORIGIN}
 					if ! $origin;
 	$country	= $::Values->{$::Variable->{UPS_COUNTRY_FIELD}}
 					if ! $country;
 	$zip		= $::Values->{$::Variable->{UPS_POSTCODE_FIELD}}
 					if ! $zip;
+
 	$country = uc $country;
+
+	# In the U.S., UPS only wants the 5-digit base ZIP code, not ZIP+4
+	$country eq 'US' and $zip =~ /^(\d{5})/ and $zip = $1;
+
 #::logGlobal("calling with: " . join("|", $mode, $origin, $zip, $weight, $country));
 	my ($shipping, $zone, $error) =
 		getUPS( $mode, $origin, $zip, $weight, $country);
 #::logGlobal("received back: " . join("|", $shipping, $zone, $error));
+
 	if($error) {
 		$Vend::Session->{ship_message} .= " $mode: $error";
 		return 0;