added shipping calculation for flat rate

This commit is contained in:
JT Smith 2008-03-13 13:57:44 +00:00
parent 819552ce06
commit e6d42bd219
3 changed files with 30 additions and 2 deletions

View file

@ -241,6 +241,19 @@ sub getTaxRate {
#-------------------------------------------------------------------
=head2 getWeight ( )
Returns 0. Needs to be overriden by subclasses.
=cut
sub getWeight {
my $self = shift;
return 0;
}
#-------------------------------------------------------------------
=head2 indexContent ( )
Adding sku as a keyword. See WebGUI::Asset::indexContent() for additonal details.

View file

@ -42,8 +42,22 @@ costs are assessed.
=cut
sub calculate {
my $self = shift;
return;
my ($self, $cart) = @_;
my $cost = 0;
my $anyShippable = 0;
foreach my $item (@{$cart->getItems}) {
my $sku = $item->getSku;
if ($sku->isShippingRequired) {
$cost += ($item->get("quantity") * $sku->getPrice * $self->get("percentageOfPrice") / 100) # cost by price
+ ($item->get("quantity") * $sku->getWeight * $self->get("percentageOfWeight") / 100) # cost by weight
+ ($item->get("quantity") * $self->get("pricePerItem")); # cost by item
$anyShippable = 1;
}
}
if ($anyShippable) {
$cost += $flatFee;
}
return $cost;
}
#-------------------------------------------------------------------