Adding the productmanager
This commit is contained in:
parent
b5998af961
commit
d12082f8ed
5 changed files with 1193 additions and 0 deletions
77
lib/WebGUI/Commerce/Item/Product.pm
Executable file
77
lib/WebGUI/Commerce/Item/Product.pm
Executable file
|
|
@ -0,0 +1,77 @@
|
|||
package WebGUI::Commerce::Item::Product;
|
||||
|
||||
use strict;
|
||||
#use WebGUI::SQL;
|
||||
use WebGUI::Product;
|
||||
|
||||
our @ISA = qw(WebGUI::Commerce::Item);
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub available {
|
||||
return $_[0]->{_variant}->{available};
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub description {
|
||||
return $_[0]->{_product}->get('description');
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
#sub duration {
|
||||
#
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
#sub handler {
|
||||
#}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub id {
|
||||
return $_[0]->{_variant}->{variantId};
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub isRecurring {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub name {
|
||||
return $_[0]->{_product}->get('title').' ('.$_[0]->{_composition}.')';
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub new {
|
||||
my ($class, $sku, $product, $variantId);
|
||||
$class = shift;
|
||||
$variantId = shift;
|
||||
|
||||
$product = WebGUI::Product->getByVariantId($variantId);
|
||||
my $variant = $product->getVariant($variantId);
|
||||
my %parameters = map {split(/\./, $_)} split(/,/, $variant->{composition});
|
||||
my $composition = join(', ',map {$product->getParameter($_)->{name} .': '. $product->getOption($parameters{$_})->{value}} keys (%parameters));
|
||||
|
||||
bless {_product => $product, _composition => $composition, _variant => $variant}, $class;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub needsShipping {
|
||||
return 1;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub price {
|
||||
return $_[0]->{_variant}->{price};
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub type {
|
||||
return 'Product';
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub weight {
|
||||
return $_[0]->{_variant}->{weight};
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue