[ic] Totally items in cart

Chad Wittrock interchange-users@interchange.redhat.com
Thu Sep 6 09:55:00 2001


I have added a 'shipping' field to the standard demo products table. I am
attempting to total the shipping values of all the items in the cart when a
person views their shopping cart. This is my code:

<snip>
                        [perl arg="carts"]
                           $ship_total = 0;

                           # Loop over all items in the main cart
                           foreach my $item ( @{$Safe{'carts'}->{'main'}} )
{
                              # Total up all the shipping costs
                              $ship_total = $ship_total +
$item->{'shipping'};
                           }
                           return ("Shipping: $ship_total");
                        [/perl]
</snip>

This returns 'Shipping: 0'. Am I doing something wrong with my calculation?

Any help is greatly appreciated.
Chad

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            ____
  |  | |\ |  ||   Chad M. Wittrock (Chad.Wittrock@uni.edu)
  \__/ | \| _||_  University of Northern Iowa