finished sku base class
This commit is contained in:
parent
1d8461aa02
commit
032617a8ba
4 changed files with 172 additions and 47 deletions
|
|
@ -10,8 +10,9 @@ The following fields are needed to construct this assets table called
|
|||
|
||||
Field Schema Description
|
||||
assetId guid The unique id assigned to this sku that may never change. It's with all assets
|
||||
revisionDate bigint
|
||||
sku varchar(35) unique The unique id that the shop keeper assigns to this item. It may be changed by the shop keeper. By default this is set equal to assetId.
|
||||
vendorId guid The unique id of the vendor associated with this sku, if any
|
||||
salesAgentId guid The unique id of the vendor associated with this sku, if any
|
||||
overrideTaxRate yesNo Do you want to use an override for tax rate?
|
||||
taxRateOverride float An override value for the default tax rate.
|
||||
|
||||
|
|
@ -24,7 +25,7 @@ class.
|
|||
|
||||
Adds this sku to the shopping cart.
|
||||
|
||||
param: optionsHash - Takes an options hash and calls applyOptions() if specified as a shortcut.
|
||||
param: options - Takes an options hash reference and calls applyOptions() if specified as a shortcut.
|
||||
|
||||
=head3 applyOptions
|
||||
|
||||
|
|
|
|||
|
|
@ -27,10 +27,28 @@ my $session = start(); # this line required
|
|||
insertCommerceTaxTable($session);
|
||||
insertCommerceShipDriverTable($session);
|
||||
migrateToNewCart($session);
|
||||
createSkuAsset($session);
|
||||
|
||||
finish($session); # this line required
|
||||
|
||||
|
||||
#-------------------------------------------------
|
||||
sub createSkuAsset {
|
||||
my $session = shift;
|
||||
print "\tCreate SKU asset.\n" unless ($quiet);
|
||||
$session->db->write("create table sku (
|
||||
assetId varchar(22) binary not null,
|
||||
revisionDate bigint not null,
|
||||
sku varchar(35) binary not null,
|
||||
salesAgentId varchar(22) binary,
|
||||
overrideTaxRate int not null default 0,
|
||||
taxRateOverride float not null default 0.00,
|
||||
primary key (assetId, revisionDate),
|
||||
unique key sku (sku),
|
||||
index vendorId (vendorId)
|
||||
)");
|
||||
}
|
||||
|
||||
#-------------------------------------------------
|
||||
sub migrateToNewCart {
|
||||
my $session = shift;
|
||||
|
|
|
|||
|
|
@ -54,56 +54,23 @@ These methods are available from this class:
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 definition ( session, definition )
|
||||
=head2 addToCart ( options )
|
||||
|
||||
See super class.
|
||||
Adds this sku to the current session's cart.
|
||||
|
||||
=head3 options
|
||||
|
||||
A hash reference as generated by getOptions().
|
||||
|
||||
=cut
|
||||
|
||||
sub definition {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $definition = shift;
|
||||
my %properties;
|
||||
tie %properties, 'Tie::IxHash';
|
||||
my $i18n = WebGUI::International->new($session, "Asset_NewAsset");
|
||||
%properties = (
|
||||
templateId => {
|
||||
# Determines which tab this property appears in
|
||||
tab=>"display",
|
||||
#See the list of field/control types in /lib/WebGUI/Form/
|
||||
fieldType=>"template",
|
||||
defaultValue=>'NewAssetTmpl0000000001',
|
||||
#www_editSave will ignore anyone's attempts to update this field if this is set to 1
|
||||
noFormPost=>0,
|
||||
#This is an option specific to the template fieldType.
|
||||
namespace=>"NewAsset",
|
||||
#This is what will appear when the user hovers the mouse over the label
|
||||
# of your form field.
|
||||
hoverHelp=>$i18n->get('templateId label description'),
|
||||
# This is the text that will appear to the left of your form field.
|
||||
label=>$i18n->get('templateId label')
|
||||
},
|
||||
foo => {
|
||||
tab=>"properties",
|
||||
fieldType=>"text",
|
||||
defaultValue=>undef,
|
||||
label=>$i18n->get("foo label"),
|
||||
hoverHelp=>$i18n->get("foo label help")
|
||||
}
|
||||
);
|
||||
push(@{$definition}, {
|
||||
assetName=>$i18n->get('assetName'),
|
||||
icon=>'NewAsset.gif',
|
||||
autoGenerateForms=>1,
|
||||
tableName=>'NewAsset',
|
||||
className=>'WebGUI::Asset::NewAsset',
|
||||
properties=>\%properties
|
||||
});
|
||||
return $class->SUPER::definition($session, $definition);
|
||||
sub addToCart {
|
||||
my ($self, $options) = @_;
|
||||
$self->applyOptions($options);
|
||||
my $cart = WebGUI::Shop::Cart->new($self->session);
|
||||
my $cart->addItem($self, 1);
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 applyOptions ( options )
|
||||
|
|
@ -123,9 +90,80 @@ sub applyOptions {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 definition ( session, definition )
|
||||
|
||||
See super class.
|
||||
|
||||
=cut
|
||||
|
||||
sub definition {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $definition = shift;
|
||||
my %properties;
|
||||
tie %properties, 'Tie::IxHash';
|
||||
my $i18n = WebGUI::International->new($session, "Asset_Sku");
|
||||
%properties = (
|
||||
sku => {
|
||||
tab=>"commerce",
|
||||
fieldType=>"text",
|
||||
defaultValue=>$session->id->generate,
|
||||
label=>$i18n->get("sku"),
|
||||
hoverHelp=>$i18n->get("sku help")
|
||||
},
|
||||
overrideTaxRate => {
|
||||
tab=>"commerce",
|
||||
fieldType=>"text",
|
||||
defaultValue=>$session->id->generate,
|
||||
label=>$i18n->get("override tax rate"),
|
||||
hoverHelp=>$i18n->get("override tax rate help")
|
||||
},
|
||||
taxRateOverride => {
|
||||
tab=>"commerce",
|
||||
fieldType=>"float",
|
||||
defaultValue=>0.00,
|
||||
label=>$i18n->get("tax rate override"),
|
||||
hoverHelp=>$i18n->get("tax rate override help")
|
||||
},
|
||||
salesAgentId => {
|
||||
tab=>"commerce",
|
||||
fieldType=>"hidden",
|
||||
defaultValue=>undef,
|
||||
label=>$i18n->get("sales agent"),
|
||||
hoverHelp=>$i18n->get("sales agent help")
|
||||
},
|
||||
);
|
||||
push(@{$definition}, {
|
||||
assetName=>$i18n->get('assetName'),
|
||||
icon=>'Sku.gif',
|
||||
autoGenerateForms=>1,
|
||||
tableName=>'sku',
|
||||
className=>'WebGUI::Asset::Sku',
|
||||
properties=>\%properties
|
||||
});
|
||||
return $class->SUPER::definition($session, $definition);
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getEditTabs ( )
|
||||
|
||||
Not to be modified, just defines a new tab.
|
||||
|
||||
=cut
|
||||
|
||||
sub getEditTabs {
|
||||
my $self = shift;
|
||||
my $i18n = WebGUI::International->new($self->session,"Asset_Sku");
|
||||
return (['commerce', $i18n->get('commerce'), 9]);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getOptions ( )
|
||||
|
||||
Returns a hash reference of configuration data that can return this sku to a configured state. See applyOptions() for details.
|
||||
Returns a hash reference of configuration data that can return this sku to a configured state. See also applyOptions().
|
||||
|
||||
=cut
|
||||
|
||||
|
|
|
|||
68
lib/WebGUI/i18n/English/Asset_Sku.pm
Normal file
68
lib/WebGUI/i18n/English/Asset_Sku.pm
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
package WebGUI::i18n::English::Asset_Sku;
|
||||
|
||||
use strict;
|
||||
|
||||
our $I18N = {
|
||||
'commerce' => {
|
||||
message => q|Commerce|,
|
||||
lastUpdated => 0,
|
||||
context => q|The name of a tab that all Sku based assets have to put their commerce related settings.|
|
||||
},
|
||||
|
||||
'sku' => {
|
||||
message => q|SKU|,
|
||||
lastUpdated => 0,
|
||||
context => q|Abbreviation for "Stock Keeping Unit" which is used as a product number or other such record keeping number.|
|
||||
},
|
||||
|
||||
'sku help' => {
|
||||
message => q|Stands for Stock Keeping Unit, which is just a fancy term for an inventory code or product number.|,
|
||||
lastUpdated => 0,
|
||||
context => q|help for sku field|
|
||||
},
|
||||
|
||||
'sales agent' => {
|
||||
message => q|sales agent|,
|
||||
lastUpdated => 0,
|
||||
context => q|asset field relating to who is selling this product|
|
||||
},
|
||||
|
||||
'sales agent help' => {
|
||||
message => q|Which person/company defined in the commerce system should get credit for selling this item, if any?|,
|
||||
lastUpdated => 0,
|
||||
context => q|help for sales agent field|
|
||||
},
|
||||
|
||||
'override tax rate' => {
|
||||
message => q|Override tax rate?|,
|
||||
lastUpdated => 0,
|
||||
context => q|A yes/no field asking whether to override tax rate.|
|
||||
},
|
||||
|
||||
'override tax rate help' => {
|
||||
message => q|Would you like to override the default tax rate for this item? Usually used in locales that have special or no tax on life essential items like food and clothing.|,
|
||||
lastUpdated => 0,
|
||||
context => q|help for override tax rate field|
|
||||
},
|
||||
|
||||
'tax rate override' => {
|
||||
message => q|Tax Rate Override|,
|
||||
lastUpdated => 0,
|
||||
context => q|a field containing the percentage to use to calculate tax for this item|
|
||||
},
|
||||
|
||||
'tax rate override help' => {
|
||||
message => q|What is the new percentage that should be used to calculate tax on this item?|,
|
||||
lastUpdated => 0,
|
||||
context => q|help for tax rate override field|
|
||||
},
|
||||
|
||||
'assetName' => {
|
||||
message => q|Sku|,
|
||||
lastUpdated => 0,
|
||||
context => "The name of this asset."
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
1;
|
||||
Loading…
Add table
Add a link
Reference in a new issue