From cdd57ea22148e887150218c32db1060f9b41e3a0 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Tue, 29 Apr 2008 23:32:38 +0000 Subject: [PATCH] Begin rebuilding variants as simple collateral. --- docs/upgrades/upgrade_7.5.10-7.5.11.pl | 7 ++- lib/WebGUI/Asset/Sku/Product.pm | 61 ++++++++++++++++++++++++ lib/WebGUI/i18n/English/Asset_Product.pm | 42 +++++++++++++++- 3 files changed, 104 insertions(+), 6 deletions(-) diff --git a/docs/upgrades/upgrade_7.5.10-7.5.11.pl b/docs/upgrades/upgrade_7.5.10-7.5.11.pl index d903eff00..ef423d93e 100644 --- a/docs/upgrades/upgrade_7.5.10-7.5.11.pl +++ b/docs/upgrades/upgrade_7.5.10-7.5.11.pl @@ -602,10 +602,9 @@ sub mergeProductsWithCommerce { my $session = shift; print "\tMerge old Commerce Products to new SKU based Products.\n" unless ($quiet); $session->db->write(<<'EOSQL'); -CREATE TABLE Product_Variants ( - sku VARCHAR(255) binary NOT NULL primary key, - mastersku VARCHAR(255) binary NOT NULL, - title VARCHAR(255), +CREATE TABLE Product_variants ( + sku VARCHAR(255) BINARY NOT NULL PRIMARY KEY, + mastersku VARCHAR(255) BINARY NOT NULL, shortdesc VARCHAR(30), price FLOAT, weight FLOAT, diff --git a/lib/WebGUI/Asset/Sku/Product.pm b/lib/WebGUI/Asset/Sku/Product.pm index b1cec58b4..9c25a5d66 100644 --- a/lib/WebGUI/Asset/Sku/Product.pm +++ b/lib/WebGUI/Asset/Sku/Product.pm @@ -898,6 +898,67 @@ sub www_editSpecificationSave { return $self->www_editSpecification("new"); } +#------------------------------------------------------------------- +sub www_editVariant { + my $self = shift; + my $sku = shift || $self->session->form->process("sku"); + return $self->session->privilege->insufficient() unless ($self->canEdit); + my ($data, $f, $hashRef); + my $i18n = WebGUI::International->new($self->session,'Asset_Product'); + $data = $self->getCollateral("Product_specification","Product_specificationId",$sku); + $f = WebGUI::HTMLForm->new($self->session,-action=>$self->getUrl); + $f->readonly( + -name => "mastersku", + -value => $data->{mastersku}, + ); + $f->hidden( + -name => "func", + -value => "editVariantSave", + ); + $f->integer( + -name => "shortdesc", + -size => 30, + -label => $i18n->get('shortdesc'), + -hoverHelp => $i18n->get('shortdesc description'), + -value => $data->{price}, + ); + $f->integer( + -name => "price", + -label => $i18n->get(10), + -hoverHelp => $i18n->get('10 description'), + -value => $data->{price}, + ); + $f->float( + -name => "weight", + -label => $i18n->get('weight'), + -hoverHelp => $i18n->get('weight description'), + -value => $data->{weight}, + ); + $f->integer( + -name => "quantity", + -label => $i18n->get('quantity'), + -hoverHelp => $i18n->get('quantity description'), + -value => $data->{quantity}, + ); + $f->submit; + return $self->getAdminConsole->render($f->print, 'add variant'); +} + +#------------------------------------------------------------------- +sub www_editVariantSave { + my $self = shift; + return $self->session->privilege->insufficient() unless ($self->canEdit); + $self->setCollateral("Product_variants", "Product_specificationId", { + Product_specificationId => $self->session->form->process("sid"), + shortdesc => $self->session->form->process('shortdesc', 'text'), + price => $self->session->form->process('name', 'float'), + weight => $self->session->form->process('weight', 'float'), + quantity => $self->session->form->process('quantity', 'integer'), + }); + + return $self->www_editVariant("new"); +} + #------------------------------------------------------------------- sub www_moveAccessoryDown { my $self = shift; diff --git a/lib/WebGUI/i18n/English/Asset_Product.pm b/lib/WebGUI/i18n/English/Asset_Product.pm index 11f735a90..64592c705 100644 --- a/lib/WebGUI/i18n/English/Asset_Product.pm +++ b/lib/WebGUI/i18n/English/Asset_Product.pm @@ -398,8 +398,8 @@ our $I18N = { }, '10 description' => { - message => q|The price of this product. You may optionally enter text like "call for pricing" if you wish, or you may leave it blank.|, - lastUpdated => 1120332527, + message => q|The price of this variant.|, + lastUpdated => 1209496419, }, '7 description' => { @@ -634,6 +634,44 @@ be useful, others may not.|, lastUpdated => 1164841201 }, + 'weight' => { + message => q|Weight|, + context => q|How much something weighs, with no units| + lastUpdated => 1209494301, + }, + + 'weight description' => { + message => q|The default weight of the variant.|, + lastUpdated => 1209494298, + }, + + 'quantity' => { + message => q|Quantity|, + lastUpdated => 1209494301, + }, + + 'quantity description' => { + message => q|How many units of this variant are available.|, + lastUpdated => 1209494298, + }, + + 'shortdesc' => { + message => q|Short Description|, + lastUpdated => 1209494301, + }, + + 'shortdesc description' => { + message => q|The will be displayed to the user so they can purchase this variant of your product.|, + lastUpdated => 1209494298, + }, + + 'add variant' => { + message => q|Add Variant.|, + context => q|Add a variant to this product. For example, if you sell shirts, this could be a large shirt, a blue shirt, or + a large blue shirt.|, + lastUpdated => 1209494298, + }, + }; 1;