[ic] Totally items in cart (sum shipping cost)

Jeffrey Carnahan interchange-users@interchange.redhat.com
Thu Sep 6 10:52:00 2001


}                         [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]

If you have a field called 'shipping' for each product in the products
database, and you've defined this in the products database definition, and
you've restarted your catalog, you should be able to use the following:

[perl tables="products"]
  my $` = 0;

  foreach $item ($Carts->{'main'}) {
    $ship_total += $Tag->data('products', 'shipping', $item->{'code'});
  }

  return "Shipping Total: $ship_total";
[/perl]

Note that I'm assuming the name of your products database is "products". You
need to use the [data ... ] tag here because arbitrary fields associated
with products (such as the "shipping" field you've defined) aren't kept with
the shopping cart information. Only quantity, code, options, and DB source
information are kept in the cart.

The above code is untested, but should give you a starting point.

--
Jeff Carnahan - jcarnahan@networq.com