diff --git a/lib/WebGUI/Asset/Sku.pm b/lib/WebGUI/Asset/Sku.pm index e08cce280..3b6622eaf 100644 --- a/lib/WebGUI/Asset/Sku.pm +++ b/lib/WebGUI/Asset/Sku.pm @@ -634,7 +634,7 @@ sub setTaxConfiguration { #------------------------------------------------------------------- -=head2 shipsSeparately +=head2 isShippingSeparately Returns a boolean indicating whether this item must be shipped separately from other items. If the shipsSeparately property is true, but isShippingRequired is false, this will return @@ -642,7 +642,7 @@ false. =cut -sub shipsSeparately { +sub isShippingSeparately { my ($self) = @_; return $self->isShippingRequired && $self->shipsSeparately; } diff --git a/lib/WebGUI/Shop/ShipDriver/FlatRate.pm b/lib/WebGUI/Shop/ShipDriver/FlatRate.pm index e9a246296..5243aeb5e 100644 --- a/lib/WebGUI/Shop/ShipDriver/FlatRate.pm +++ b/lib/WebGUI/Shop/ShipDriver/FlatRate.pm @@ -60,7 +60,7 @@ sub calculate { ## Two items shipped separately = two bundles ## 1 shipped separately plus 1 not = two bundles ## two items shipped together = one bundle - if ($sku->shipsSeparately) { + if ($sku->isShippingSeparately) { $separatelyShipped += $quantity; } else { diff --git a/lib/WebGUI/Shop/ShipDriver/USPS.pm b/lib/WebGUI/Shop/ShipDriver/USPS.pm index 23e5faba3..b12e37246 100644 --- a/lib/WebGUI/Shop/ShipDriver/USPS.pm +++ b/lib/WebGUI/Shop/ShipDriver/USPS.pm @@ -66,7 +66,7 @@ sub buildXML { my $itemWeight = $sku->getWeight(); ##Items that ship separately with a quantity > 1 are rate estimated as 1 item and then the ##shipping cost is multiplied by the quantity. - if (! $sku->shipsSeparately ) { + if (! $sku->isShippingSeparately ) { $itemWeight *= $item->get('quantity'); } $weight += $itemWeight; @@ -193,7 +193,7 @@ sub _calculateFromXML { WebGUI::Error::RemoteShippingRate->throw(error => "Illegal package index returned by USPS: $id"); } my $unit = $shippableUnits[$id]; - if ($unit->[0]->getSku->shipsSeparately) { + if ($unit->[0]->getSku->isShippingSeparately) { ##This is a single item due to ships separately. Since in reality there will be ## N things being shipped, multiply the rate by the quantity. $cost += $rate * $unit->[0]->get('quantity'); @@ -339,7 +339,7 @@ sub _getShippableUnits { ITEM: foreach my $item (@{$cart->getItems}) { my $sku = $item->getSku; next ITEM unless $sku->isShippingRequired; - if ($sku->shipsSeparately) { + if ($sku->isShippingSeparately) { push @shippableUnits, [ $item ]; } else { diff --git a/t/Asset/Sku.t b/t/Asset/Sku.t index e11988107..9d67cddb1 100644 --- a/t/Asset/Sku.t +++ b/t/Asset/Sku.t @@ -30,16 +30,18 @@ my $session = WebGUI::Test->session; #---------------------------------------------------------------------------- # Tests -plan tests => 21; # Increment this number for each test you create +plan tests => 22; # Increment this number for each test you create #---------------------------------------------------------------------------- # put your tests here my $root = WebGUI::Asset->getRoot($session); +warn "Make sku\n"; my $sku = $root->addChild({ className=>"WebGUI::Asset::Sku", title=>"Test Sku", }); isa_ok($sku, "WebGUI::Asset::Sku"); +addToCleanup($sku); $sku->addToCart; @@ -64,13 +66,14 @@ is($sku->isRecurring, 0, "skus are not recurring by default"); is($sku->isShippingRequired, 0, "skus are not shippable by default"); is($sku->getConfiguredTitle, $sku->getTitle, "configured title and title should be the same by default"); is($sku->shipsSeparately, 0, 'shipsSeparately return 0 by default'); +is($sku->isShippingSeparately, 0, 'isShippingSeparately return 0 by default'); -$sku->update({shipsSeparately => 1,}); -is($sku->shipsSeparately, 0, 'shipsSeparately only returns true when isShippingRequired AND shipsSeparately'); +$sku->shipsSeparately(1); +is($sku->isShippingSeparately, 0, 'isShippingSeparately only returns true when isShippingRequired AND shipsSeparately'); { local *WebGUI::Asset::Sku::isShippingRequired = sub { return 1}; - is($sku->shipsSeparately, 1, 'shipsSeparately only returns true when isShippingRequired AND shipsSeparately'); + is($sku->isShippingSeparately, 1, 'isShippingSeparately only returns true when isShippingRequired AND shipsSeparately'); } ok(! $sku->isShippingRequired, 'Making sure that GLOB is no longer in effect'); @@ -82,13 +85,3 @@ $item->cart->delete; my $loadSku = WebGUI::Asset::Sku->newBySku($session, $sku->get("sku")); is($loadSku->getId, $sku->getId, "newBySku() works."); - -#---------------------------------------------------------------------------- -# Cleanup -END { - -$sku->purge; - -} - -1;