[ic] interchange error
John Rennie
john.rennie at thechampagneshop.co.uk
Fri Oct 24 09:58:10 EDT 2003
> UserTag batch Routine <<EOR
> sub {
> foreach my $index (0 .. $#$Vend::Items) {
> my $code = $Vend::Items->[$index]{code};
> my $oqty = $Vend::Items->[$index]{quantity};
> my $base = $Vend::Items->[$index]{mv_ib};
> my $nqty = $oqty;
> my $batches = undef;
>
> my $min = Vend::Data::database_field($base, $code,
> "min_qty", undef);
> my $batch = Vend::Data::database_field($base, $code,
> "batch_qty", undef);
>
> $batch = 1 if $batch <= 1;
> $min = 1 if $min <= 1;
> $nqty = 0 if $nqty <= $min;
> $nqty = $nqty - $min if $nqty > $min;
>
> $batches = int($nqty / $batch);
> $nqty = $min + $batches * $batch;
>
> my $message = <<EOM;
> <br>
> <p style="font-size: 10px">
> You must order at least $min items.
> </p>
> <p style="font-size: 10px">
> Additional items must be ordered in multiples of $batch.
> </p>
> EOM
>
> $Vend::Items->[$index]{quantity} = $nqty;
> $Vend::Items->[$index]{message} = $message if $oqty != $nqty;
> $Vend::Items->[$index]{message} = "" if $oqty == $nqty;
> }}
> EOR
>
How about the foreach loop running once too often? I think it will
run $#$Vend::Items + 1 times, as you're starting at zero and counting
to $#$Vend::Items?
Regards,
John.
More information about the interchange-users
mailing list