[ic] Modified Shipping

Ed LaFrance interchange-users@icdevgroup.org
Tue Jul 1 11:22:00 2003


At 08:01 PM 6/30/2003 -0700, you wrote:
>Hi all
>I am trying to alter shiping by a category field I created in the products
>table. From the archives I believed that this UserTag would work but it is
>not.. Can someone point out what I am doing wrong?
>
>Thanks in advance
>
>
>UserTag smallbiz_ship Routine <<EOR
>sub {
>         my $total = 0;
>         my $n = 0;
>         my $item_quant = 0;
>         my $total_item_quant = 0;
>         my $ship_charge=0;
>         my $add_ship_charge=0;
>         my $ship_cat = "";
>         my $sku = "";
>         for my $item (@$Items) {
>                 $sku = $item->{sku}; # also tried $item->{code};
>                 $item_quant = $item->{quantity};
>                 $total_item_quant += $item_quant;
>                 $ship_cat = $Tag->query( {  sql => "select ship_cat from
>product
>s where sku='$sku'", wantarray => 1 } );
>                 $ship_cat = $ship_cat->[0]->[0];
>                 if ($ship_cat eq '2') {
>                         $ship_charge ="8.95";
>                         $add_ship_charge= "2.95";
>                 }
>                 if ($n eq "0") {
>                         $total = $ship_charge;
>                         if ($item_quant > 1) {
>                                 $item_quant = $item_quant - 1;
>                                 $total += $item_quant*2;
>                         }
>                 } else {
>                         $total += $item_quant*2;
>                 }
>         $total = $ship_cat;
>         }
>         return $total;
>}
>EOR

Looks mostly ok, but you are not doing anything with the final total within 
this tag except returning it. To set the shipping to total you would need 
to use [assign shipping="[smallbiz_ship]"] in your ITL or do a 
$Tag->assign( { shipping => $total } ) in the last line of your usertag.

- Ed L.


===============================================================
New Media E.M.S.              Technology Solutions for Business
463 Main St., Suite D         eCommerce | Consulting | Hosting
Placerville, CA  95667        edl@newmediaems.com
(530) 622-9421                http://www.newmediaems.com
(866) 519-4680 Toll-Free      (530) 622-9426 Fax
===============================================================