Adding Shipping plugins
This commit is contained in:
parent
8dc80f6e2d
commit
2d2228e266
3 changed files with 152 additions and 0 deletions
52
lib/WebGUI/Commerce/Shipping/ByPrice.pm
Normal file
52
lib/WebGUI/Commerce/Shipping/ByPrice.pm
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
package WebGUI::Commerce::Shipping::ByPrice;
|
||||
|
||||
our @ISA = qw(WebGUI::Commerce::Shipping);
|
||||
|
||||
use strict;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub calc {
|
||||
my ($self, $items, $price);
|
||||
$self = shift;
|
||||
|
||||
$items = $self->getShippingItems;
|
||||
|
||||
foreach (@$items) {
|
||||
$price += $_->{totalPrice};
|
||||
}
|
||||
|
||||
return $price * $self->get('percentageOfPrice') / 100;
|
||||
};
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub configurationForm {
|
||||
my ($self, $f);
|
||||
$self = shift;
|
||||
|
||||
$f = WebGUI::HTMLForm->new;
|
||||
$f->float(
|
||||
-name => $self->prepend('percentageOfPrice'),
|
||||
-label => WebGUI::International::get('percentage of price', 'CommerceShippingByPrice'),
|
||||
-value => $self->get('percentageOfPrice')
|
||||
);
|
||||
|
||||
return $self->SUPER::configurationForm($f->printRowsOnly);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub init {
|
||||
my ($class, $self);
|
||||
$class = shift;
|
||||
|
||||
$self = $class->SUPER::init('ByPrice');
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub name {
|
||||
return WebGUI::International::get('title', 'CommerceShippingByPrice');
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
52
lib/WebGUI/Commerce/Shipping/ByWeight.pm
Normal file
52
lib/WebGUI/Commerce/Shipping/ByWeight.pm
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
package WebGUI::Commerce::Shipping::ByWeight;
|
||||
|
||||
our @ISA = qw(WebGUI::Commerce::Shipping);
|
||||
|
||||
use strict;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub calc {
|
||||
my ($self, $items, $weight);
|
||||
$self = shift;
|
||||
|
||||
$items = $self->getShippingItems;
|
||||
|
||||
foreach (@$items) {
|
||||
$weight += $_->{item}->weight * $_->{quantity};
|
||||
}
|
||||
|
||||
return $weight * $self->get('pricePerUnitWeight');
|
||||
};
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub configurationForm {
|
||||
my ($self, $f);
|
||||
$self = shift;
|
||||
|
||||
$f = WebGUI::HTMLForm->new;
|
||||
$f->float(
|
||||
-name => $self->prepend('pricePerUnitWeight'),
|
||||
-label => WebGUI::International::get('price per weight', 'CommerceShippingByWeight'),
|
||||
-value => $self->get('pricePerUnitWeight')
|
||||
);
|
||||
|
||||
return $self->SUPER::configurationForm($f->printRowsOnly);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub init {
|
||||
my ($class, $self);
|
||||
$class = shift;
|
||||
|
||||
$self = $class->SUPER::init('ByWeight');
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub name {
|
||||
return WebGUI::International::get('title', 'CommerceShippingByWeight');
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
48
lib/WebGUI/Commerce/Shipping/PerTransaction.pm
Normal file
48
lib/WebGUI/Commerce/Shipping/PerTransaction.pm
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
package WebGUI::Commerce::Shipping::PerTransaction;
|
||||
|
||||
our @ISA = qw(WebGUI::Commerce::Shipping);
|
||||
|
||||
use strict;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub calc {
|
||||
my ($self);
|
||||
$self = shift;
|
||||
|
||||
return 0 unless (scalar(@{$self->getShippingItems}));
|
||||
|
||||
return $self->get('pricePerTransaction');
|
||||
};
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub configurationForm {
|
||||
my ($self, $f);
|
||||
$self = shift;
|
||||
|
||||
$f = WebGUI::HTMLForm->new;
|
||||
$f->float(
|
||||
-name => $self->prepend('pricePerTransaction'),
|
||||
-label => WebGUI::International::get('price', 'CommerceShippingPerTransaction'),
|
||||
-value => $self->get('pricePerTransaction')
|
||||
);
|
||||
|
||||
return $self->SUPER::configurationForm($f->printRowsOnly);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub init {
|
||||
my ($class, $self);
|
||||
$class = shift;
|
||||
|
||||
$self = $class->SUPER::init('PerTransaction');
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub name {
|
||||
return WebGUI::International::get('title', 'CommerceShippingPerTransaction');
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue