[ic] $Tag->shipping and adder problem
Bruno Cantieni
bruno at digi-land.com
Thu Feb 15 10:48:02 EST 2007
> Quoting Bruno Cantieni (bruno at digi-land.com):
> > > Hi all.
> > > I need to calculate the shipping cost for all the available
> > > methods and
> > > store this in a hash for later use.
> > > I'm doing this as per the following code (excerpt only):
> > > [calc]
> > > #some code here
> > > foreach my $mode (@modes) {
> > > $shipping_hash{'shipmode'}{$mode} = $Tag->shipping_desc(
> > > $mode );
> > > $shipping_hash{'shipcost'}{$mode} =
> > > $Tag->shipping($mode);
> > > }
> > > #some more code
> > > return;
> > > [/calc]
> > >
> > > The cost returned by $Tag->shipping($mode) does not include
> > > the "adder" (and
> > > possibly other modifiers) as defined in shipping.asc
> > >
> > > I checked this also by doing the following (the adder is 2 in
> > > this example):
> > > [calc]return $Tag->shipping('upsg ');[/calc] returns 10.23
> > > [shipping upsg] returns $12.23
> > >
> > > What gives??
> > >
> > >
> > >
> > > Bruno Cantieni
> > >
> > Hi again.
> > I checked this out on a totally different install, on a
> totally different
> > server.
> > Both run 5.2.0
> > With a upsg method set I get the following results:
> >
> > A) no minimum, no adder, basic charge $3.02
> > [calc]return $Tag->shipping('upsg ');[/calc] returns 3.02
> > [shipping upsg] returns $3.02
> >
> > B) $5 minimum, no adder, basic charge $3.02
> > [calc]return $Tag->shipping('upsg ');[/calc] returns 5.00
> > [shipping upsg] returns $5.00
> >
> > C) $5 minimum, $5 adder, basic charge $3.02
> > [calc]return $Tag->shipping('upsg ');[/calc] returns 5.00
> > [shipping upsg] returns $8.02
> >
> > D) $5 minimum, $5 adder, basic charge 8.73
> > [calc]return $Tag->shipping('upsg ');[/calc] returns 8.73
> > [shipping upsg] returns $13.73
> >
> > The conclusion:
> > $Tag->shipping() honours the minimum but not the adder :(
> > Bug?
>
> You don't mention what your Adder is. I bet if you made it a flat 5.00
> it would work. But I bet you have a [calc] or something producing it.
>
> You can't use $Tag->shipping() in a calc unless you have 5.5,
> I think. The problem is that the eval will not work in the safe
> compartment of the [calc].
>
> Also, if you have any database tables that are opened in the
> shipping mode you are using, they may not work unless you use
> [perl tables="tables that need to be opened"] instead of [calc].
>
> --
> Mike Heins
Thanks for having a look at this as well Mike.
I started this out by using [perl tables="foo bar"] and it makes no
difference.
My adders are straight values in the shipping.asc, not calculated via
[calc].
Here is my plain vanilla shipping.asc entry for upsg:
upsg UPS Ground weight 0 0 e Nothing to ship!
{'at_least' => "5.75",'adder' => "2",'geo' => "zip",'ups' => "1",'zone' =>
"450",'ui_ship_type' => "UPSI",'table' => "Ground",}
upsg UPS Ground weight 0 150 u Ground [value name=zip
filter=digits default=45056] {'PriceDivide' => "1",}
upsg UPS Ground weight 150 999999 e @@TOTAL@@ lbs too heavy
for UPS {'PriceDivide' => "1",}
Here are the results of various approaches of my latest test:
[shipping upsg] returns the correct $10.60
[calc]return $Tag->shipping('upsg');[/calc] returns the incorrect 8.60
[perl tables="holiday Ground 2ndDayAir 3DaySelect GroundRes GroundComm
NextDayAir NextDayAirSaver"]return $Tag->shipping('upsg');[/perl] returns
the equally incorrect 8.60, same as the calc tag.
I tried to solve the problem with the following hack, alas that doesn't work
as expected:
[calc interpolate=1]
#more code above
foreach my $mode (@modes) {
$Values->{mv_shipmode} = $mode;
$shipping_hash{$mode}{'cost'} = '[shipping interpolate=1]';
}
#more code below
return;
[calc]
In the above, [shipping interpolate=1] returns the same value (default upsg)
regardless of $Values->{mv_shipmode}.
PS. Switching the shipping.asc to notes type format also did not resolve the
issue.
Regards,
Bruno Cantieni
More information about the interchange-users
mailing list