[ic] questions about shipping
Kevin Walsh
kevin at cursor.biz
Fri Nov 11 16:04:33 EST 2005
JT Justman [jt at airdelights.com] wrote:
> My solution was to create a custom field on products called dim_weight,
> and populate it for the item with the dimensional weight based on the
> formula:
>
> Dimensional Weight = (length x width x height)/194
>
> Then in shipping.asc I use something like
>
> criteria <<EOF
> [perl]
> my $total = 0;
> foreach my $item (@$Items) {
> $total += $item->{quantity} * $item->{dim_weight} > $item->{weight} ?
> $item->{dim_weight} : $item->{weight};
> }
> return $total;
> [/perl]
> EOF
>
> What I actually use is more complicated, so I this is off the cuff and
> probably won't work. The idea is to return the total of the bigger weight
> column.
>
I haven't tested this either, by the way, but it looks reasonable.
The only problem I can see in the above is an operator precedence
error.
You will need parenthesis around the code to the right of the *, so
it's "quantity * (...whichever weight...)".
Oh, and [calcn] will be more efficient than [perl] for the above. As
it's a one-shot operation, it probably won't make too much difference
and, as you said, it was only an example.
--
_/ _/ _/_/_/_/ _/ _/ _/_/_/ _/ _/
_/_/_/ _/_/ _/ _/ _/ _/_/ _/ K e v i n W a l s h
_/ _/ _/ _/ _/ _/ _/ _/_/ kevin at cursor.biz
_/ _/ _/_/_/_/ _/ _/_/_/ _/ _/
More information about the interchange-users
mailing list