Add a billing address to the cart. Add form processing for an address form to the AddressBook. Support for choosing shipping methods without an address.

This commit is contained in:
Colin Kuskie 2010-04-26 09:30:40 -07:00
parent 8504a34c65
commit 9838d20458
6 changed files with 134 additions and 59 deletions

View file

@ -84,7 +84,14 @@ sub getDrivers {
=head2 getOptions ( $cart )
Returns a list of options for the user to ship, along with the cost of using each one. It is a hash of hashrefs,
with the key of the primary hash being the shipperId of the driver, and sub keys of label and price.
with the key of the primary hash being the shipperId of the driver, and sub keys of label, price, and whether the
price actually exists, to tell the difference between 0 and unknown.
{
label => 'ShipDriver label',
price => \d+,
hasPrice => 1 || 0,
}
=head3 $cart
@ -99,15 +106,24 @@ sub getOptions {
my %options = ();
SHIPPER: foreach my $shipper (@{$self->getShippers()}) {
next SHIPPER unless $shipper->get('enabled');
my $price = eval { $shipper->calculate($cart) };
if (my $e = WebGUI::Error->caught()) {
$self->session->log->warn($e->error);
next SHIPPER;
}
next SHIPPER unless $shipper->canUse;
my ($price, $hasPrice);
if ($cart->get('shippingAddressId')) {
my $price = eval { $shipper->calculate($cart) };
if (my $e = WebGUI::Error->caught()) {
$self->session->log->warn($e->error);
next SHIPPER;
}
$hasPrice = 1;
}
else {
$price = 0;
$hasPrice = 0;
}
$options{$shipper->getId} = {
label => $shipper->get("label"),
price => $price,
label => $shipper->get("label"),
price => $price,
hasPrice => 0,
};
}
return \%options;