[ic] Size based shipping

Rick Eicher II interchange-users@interchange.redhat.com
Tue Dec 4 12:31:53 2001


> > ...
> >
> > > > When i load an item into the cart it gives me a shipping cost of
> > > > $154,792,564.00 for a medium
> > > > and $154,792,620.00 for a large. Now while i plan to retire
> > > > someday I do not
> > > > think I will get many sales on this site.:)
> > > >
> > > > So what have I done wrong? lol To me the code looks write but
> > I know that
> > > > one can not proof read there own essay.
> > > >
> > > > I am useing redhat 7.1 and interchange 4.8.3(rpm). Not that that
> > > > will matter
> > > > much.
> > >
> > > Here is my latest version of the usertag in my catalog.cfg:
> > >
> > > #Shipping user tag
> > >
> > > UserTag ship Routine <<EOF
> > > sub{
> > > package Vend::Interpolate;
> > > my $total =0;
> > > [item-list]
> > > if ([item-modifier size] =~ /^s/i) {$total += ([nitems] * 8.95);}
> > > if ([item-modifier size] =~ /^m/i) {$total += ([nitems] * 9.95);}
> > > if ([item-modifier size] =~ /^l/i) {$total += ([nitems] * 10.95);}
> > > if ([item-modifier size] =~ /^xl/i) {$total += ([nitems] * 11.95);}
> > > [/item-list]
> > > return $total;
> > > }
> >
> If I make the usertag like this:
>
> UserTag ship Routine <<EOF
> sub{
> package Vend::Interpolate;
> my $total =0;
>
> {$total += (9.95);}
>
> return $total;
> }
> EOF
>
>
> Then it works. :) (gives 9.95 as the shipping) But as soon as I
> try and add
> any tag I get $153 million or so for the shipping. Even the
> [item-list]tags.
>
> It seems to me that it is not interpreting the tags correctly. Have i left
> some thing out that would let it use the tags?
>
> Thanks
> Rick
After doing so research i have come to the decition that I can not use tags
inside my usertag. So I have redone the usertag as follows:

UserTag ship Routine <<EOF
sub{
package Vend::Interpolate;
my $total =0;

for (@$Items) {
if {$_->{size} =~ /^s/i} {$total += $_->{quantity} * 8.95;}
if {$_->{size} =~ /^m/i} {$total += $_->{quantity} * 9.95;}
if {$_->{size} =~ /^l/i} {$total += $_->{quantity} * 10.95;}
if {$_->{size} =~ /^xl/i} {$total += $_->{quantity} * 11.95;}
}
return $total;
}
EOF

But I still get shipping of around 153 million.

Any ideas?
rick