[ic] How to obtain discount price from the shopping cart

Jim Boyer interchange-users@icdevgroup.org
Mon Jun 30 11:54:00 2003


I am having a problem finding how I can get the discount price in the 
shopping cart so I can calculate shipping.  I am using quantity 
discounting, as well as sale prices, but I can't seem to find the discount 
price inside my shipping usertag.  It must be simple, but I can't find it 
searching the archives or the documentation.  I am using 
IC  4.9.7-200305121041, RH Linux 7.2, with MySQL .  I can get the price 
from the products table, but that is not the discount price for 
quantities.  I have tried $item->{price} and other combinations, but I 
can't find the correct syntax.  Here is the partial of my usertag where I 
am getting the price from the products table.

Thanks for any help,

--------------------------------------------------
      my $cart = $Carts->{main};

      # loop through the cart items
      foreach my $item (@$cart)
      {
           $price = $Tag->data(
                    {table => 'products',
                    field => 'price',
                    key => $item->{code},}
                    );

           # add the quantity to the total number of items
           $totalItems+= $item->{quantity};

           # if sku starts with VT (video) or CD then it is an exception
           if ( ( $item->{code} =~ /^VT/ ) || ( $item->{code} =~ /^CD/ ) )
           {
                # add the quantity of the video or cd to the exceptions
                $exceptions+= $item->{quantity};
           }

           else  # sub total without the video or cd costs
           {
                # add the price * quantity to the sub total
                $subTot+= ($price * $item->{quantity});
           }
      }

---------------------------------------------------------------
Jim Boyer
Systems Programmer
Information Dept
College of Agriculture and Home Economics
Washington State University