[ic] How to obtain discount price from the shopping cart
Kevin Walsh
interchange-users@icdevgroup.org
Thu Jun 26 21:38:00 2003
Jim Boyer [boyerj@wsu.edu] wrote:
>
> I am having a problem finding how I can get the discount price in the
> shopping cart to calculate shipping. I am using quantity discounting, 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 . I can
> get the price from the products table, but that is not the discount price
> for quantities. 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});
> }
> }
>
Replace this:
$price = $Tag->data(
{table => 'products',
field => 'price',
key => $item->{code},}
);
with this:
my $price = $Tag->price({
code => $item->{code},
quantity => $item->{quantity},
noformat => 1,
});
--
_/ _/ _/_/_/_/ _/ _/ _/_/_/ _/ _/
_/_/_/ _/_/ _/ _/ _/ _/_/ _/ K e v i n W a l s h
_/ _/ _/ _/ _/ _/ _/ _/_/ kevin@cursor.biz
_/ _/ _/_/_/_/ _/ _/_/_/ _/ _/