[ic] Shipping calculation bug

Bruno Cantieni bruno at digi-land.com
Mon Aug 28 18:49:35 EDT 2006


Something looks buggy to me in the way additional shipping calculations get
handled.
We have a shipmode that calls a usertag "padding" to determine additional
shipping charges and a usertag "drop_ship_internal_lookup" to calculate the
"raw" shipping charges.
To make this work we have revisd Ship.pm to interpolate user tags as e.g.:
if (defined($o->{adder}) && $o->{adder} =~ /__\w+__|\[/);

The applicable lines in the shipping.asc would be as follows:

upsg    UPS Ground      weight  0       0       e Nothing to ship!
{'adder' => "[padding b='0' zm='07928=4.5;33014=1.5' m='[scratch drop_ship]'
oz='[scratch origin_zips]' interpolate='1']",'ups' => "0",'PriceDivide' =>
"1",'ui_ship_type' => "weight",}
upsg    UPS Ground      weight  0       999999  f [drop_ship_internal_lookup
mode=Ground]               {'PriceDivide' => "1",}

The problem we have is that while the "drop_ship_internal_lookup" tag gets
called and executes properly each and every time, the "padding" tag gets
called and executes at only arbitrary times, i.e. most of the time but
sometimes not, leading to inacurate calculations.

I have looked all over the Ship.pm, Interpolate.pm and Util.pm and I can not
put my finger on why the tag would not get called properly each and every
time shipping needs to be calculated.
I turned on ::logDebug() all over the place and got nothing insightful so
far.
The padding tag looks essentially like this:

UserTag padding Order b zm m oz
UserTag padding Routine <<EOR
sub {
	my($b,$zm,$m,$oz) = @_;
	# $b  = 'base amount to charge' via b=2
	# $zm = 'zone map'              via zm='07928=4.5;33014=1.5'
	# $m  = '# of drop shipments'   via m=[scratch drop_ship]
	# $oz = 'origin zips'           via oz=[scratch origin_zips]
	::logDebug("Starting padding calcs:"); # Simply tells me if/when the
tag gets called :(
	return undef unless $zm;
	return undef unless $oz;
	$m ||= 1;
	my %pm =  split(/[=;]/, $zm);
	my $p = $b*$m;
	foreach my $k (keys %pm) {
		if ($oz =~ /$k/) {
			$p += $pm{$k};
		}
	}
	return $p;
}
EOR

If anybody has a clue as to why the "padding" tag does not get called each
time shipping needs to be calculated, I'd appreciate some feedback.
Stumped,
Bruno Cantieni

###########################################
Digital Landscape - Cyboretum.com
Web Applications * Web Hosting * e-Commerce
http://www.digi-land.com
http://www.cyboretum.com
bruno at digi-land.com
Phone/Fax: 1+905.668.2255
Toll free: 1+877.668.2345
 



More information about the interchange-users mailing list