[ic] On the fly item quantity change?

Jerry jerry@digitalfm.com
Thu, 14 Dec 2000 07:36:13 -0500


> Quoting Mike Heins

> Nope, because the price is calculated before the [item-calc] is
> done. You have to change it in the cart itself first, then
> do the loop to display the price.
> 
> [calc]
> 	my $sku;
> 	foreach $sku (@$Vend::Items) {
> 	    delete $sku->{changed_it};
> 	    next unless $sku->{quantity} > 10;
> 	    $sku->{changed_it} = $sku->{quantity};
> 	    $sku->{quantity} = 10;
> 	}
> 	return;
> [/calc]
 
Mike,
Thank you so much. Though this didn't seem to work out of
the box so to speak, it gave me a good kick in the right 
direction. Here's what I ended up with. Seems to work just fine. 
This'll help solve a few other hair pulling items on the todo list :)

[calc arg="carts"]
	my $item;
	foreach my $item ( @{$Safe{'carts'}->{'main'}} ) 
	 {
	    delete $item->{changed_it};
	    delete $item->{changed_it};
	    next unless $item->{quantity} > 10;
	    $item->{changed_it} = $item->{quantity};
	    $item->{quantity} = 10;
	}
	return;
[/calc]

Jerry Upoff