[ic] Re: Custom UserDefined Variable Help

interchange-users@icdevgroup.org interchange-users@icdevgroup.org
Thu Sep 19 17:42:01 2002


C.B. Currier writes: 

> Trying to Set up a custom variable with a Routine that will run through a
> series of caluclations against a sql db. I am having syntax problems. Do I
> do the code as: 
> 
> 	UserTag shipping_calc Routine <<EOR
> 	sub {
> 		my $freight=0;
> 		my $itmcount = 0; 
> 
> 		my $db = $Db{store};
> 		my $tdb = $db->{SKUShipZones};
> 		my $item=$Carts->{main};
> 		foreach ($item){

Try foreach (@$item) to get an array to loop through. 

> 			$itmcount++; 
> 
> 			my $qry = $tdb->query('Select * from SKUShipZones where sku =
> $item->{code};');
> 			foreach $row(@$qry){
> 				$freight = $freight + $row->{FREIGHT};
> 			}
> 		}
> 	return $freight;
> 	}
> 	EOR 
> 
> 
> How would this work better as I get little debugging data from the error
> logs.

Posting the error message is a good idea though. 

Bye
     Racke 

 

-- 
Prolific Interchange Consulting (Excellent German Quality !).
Take a look at Materialboerse (http://www.materialboerse.de/), WITT
(http://www.witt-weiden.de/), Boxmover (http://shop.boxmover.ch/) or
Passionshop (http://www.passionshop.com/racke). Need a shop ? Contact us.