[ic] Prevent from ordering more than is in stock

Jeff Dafoe interchange-users@icdevgroup.org
Tue Oct 15 22:12:01 2002


> > [comment]dont let users add more to cart than we have in stock[/comment]
> > [perl tables=inventory]
> >   my $item;
> >   foreach $item (@{$Carts->{main}}) {
> >     my $on_hand = tag_data('inventory', 'quantity', $item->{code});
> >     next if $on_hand >= $item->{quantity};
> >     if ($on_hand<=0) {
> >       $item->{quantity} = 0;
> >       $item->{q_message} = "Item is currently out of stock.";
> >     } else {
> >       $item->{quantity} = $on_hand;
> >       $item->{q_message} = "Limited item stock, order quantity
adjusted.";
> >     }
> >   }
> > [/perl]
>
> Thanks Jeff, that's just the type of thing I was looking for. I've put
that
> at the top of ord/checkout.html, as I figure it should be parsed before
> anything else, but it doesn't seem to be having any effect on the
quantities
> (I've restarted Interchange). Any ideas?

    I am not sure, I haven't put it on my checkout page because I don't
allow quantity modification or item deletion from my checkout page.


Jeff