finished sku base class

This commit is contained in:
JT Smith 2008-02-25 20:27:21 +00:00
parent 1d8461aa02
commit 032617a8ba
4 changed files with 172 additions and 47 deletions

View file

@ -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

View 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;