The current USPS driver only works on domestic shipments.
This commit is contained in:
parent
40cec4b855
commit
c871c0372d
3 changed files with 24 additions and 5 deletions
|
|
@ -4,6 +4,7 @@
|
|||
- fixed #11202: USPS driver does not log authentication errors
|
||||
- fixed #10985: Survey: can't add multiple choice answer
|
||||
- fixed #11197: Survey Edit Console is not i18n'ed
|
||||
- fixed USPS driver only works on domestic addresses.
|
||||
|
||||
7.8.3
|
||||
- Rewrote Spectre's workflow queues to prevent it from "forgetting" about some workflows.
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ Package WebGUI::Shop::ShipDriver::USPS
|
|||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Shipping driver for the United States Postal Service.
|
||||
Shipping driver for the United States Postal Service, domestic shipping services.
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
|
|
@ -127,6 +127,9 @@ sub calculate {
|
|||
if (! $self->get('userId')) {
|
||||
WebGUI::Error::InvalidParam->throw(error => q{Driver configured without a USPS userId.});
|
||||
}
|
||||
if ($cart->getShippingAddress->get('country') ne 'United States') {
|
||||
WebGUI::Error::InvalidParam->throw(error => q{Driver only handles domestic shipping});
|
||||
}
|
||||
my $cost = 0;
|
||||
##Sort the items into shippable bundles.
|
||||
my @shippableUnits = $self->_getShippableUnits($cart);
|
||||
|
|
@ -428,6 +431,9 @@ sub _getShippableUnits {
|
|||
}
|
||||
else {
|
||||
my $zip = $item->getShippingAddress->get('code');
|
||||
if ($item->getShippingAddress->get('country') ne 'United States') {
|
||||
WebGUI::Error::InvalidParam->throw(error => q{Driver only handles domestic shipping});
|
||||
}
|
||||
push @{ $looseUnits{$zip} }, $item;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,10 +23,9 @@ use Data::Dumper;
|
|||
|
||||
use WebGUI::Test; # Must use this before any other WebGUI modules
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Shop::ShipDriver::USPS;
|
||||
|
||||
plan tests => 65;
|
||||
use_ok('WebGUI::Shop::ShipDriver::USPS')
|
||||
or die 'Unable to load module WebGUI::Shop::ShipDriver::USPS';
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
|
|
@ -224,14 +223,14 @@ my $workAddress = $addressBook->addAddress({
|
|||
organization => 'Plain Black Corporation',
|
||||
address1 => '1360 Regent St. #145',
|
||||
city => 'Madison', state => 'WI', code => '53715',
|
||||
country => 'USA',
|
||||
country => 'United States',
|
||||
});
|
||||
my $wucAddress = $addressBook->addAddress({
|
||||
label => 'wuc',
|
||||
organization => 'Madison Concourse Hotel',
|
||||
address1 => '1 W Dayton St',
|
||||
city => 'Madison', state => 'WI', code => '53703',
|
||||
country => 'USA',
|
||||
country => 'United States',
|
||||
});
|
||||
$cart->update({shippingAddressId => $workAddress->getId});
|
||||
|
||||
|
|
@ -838,6 +837,19 @@ isa_ok($e, 'WebGUI::Error::Shop::RemoteShippingRate', 'calculate throws an excep
|
|||
$properties->{userId} = $userId;
|
||||
$driver->update($properties);
|
||||
|
||||
my $dutchAddress = $addressBook->addAddress({
|
||||
label => 'dutch',
|
||||
address1 => 'Rotterdamseweg 183C',
|
||||
city => 'Delft', code => '2629HD',
|
||||
country => 'Netherlands',
|
||||
});
|
||||
|
||||
$cart->update({shippingAddressId => $dutchAddress->getId});
|
||||
$cost = eval { $driver->calculate($cart); };
|
||||
$e = Exception::Class->caught();
|
||||
isa_ok($e, 'WebGUI::Error::InvalidParam', "calculate won't calculate for foreign countries");
|
||||
|
||||
$cart->update({shippingAddressId => $workAddress->getId});
|
||||
#######################################################################
|
||||
#
|
||||
# _calculateInsurance edge case
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue