Add getAddToCartForm to skus, update Shelf code, help, i18n and template.

This commit is contained in:
Colin Kuskie 2009-03-28 17:25:43 +00:00
parent b4c60af457
commit 01b8ccf412
14 changed files with 222 additions and 4 deletions

View file

@ -2,6 +2,10 @@
- fixed #9955: Matrix alpha sort is backwards
- fixed #9934: Matrix 2.0 - Products should be listed alphabetically
- fixed #9865: Matrix: Later added attributes are not detected in older listings
- added: Sku's now have a getAddToCartForm method, which is used by the Shelf
to place a small form next to each Sku that displays. Sku's with complex
forms (like the EMS sku's), simply display a button to take the user to the
sku's view screen for the whole form. [TEMPLATE]
7.7.1
- the AdSku project: create a Sku that allows buyers to purchase advertising in select AdSpaces at selected priorities

View file

@ -159,6 +159,27 @@ sub definition {
}
#-------------------------------------------------------------------
=head2 getAddToCartForm ( )
Returns a form to add this Sku to the cart. Used when this Sku is part of
a shelf.
=cut
sub getAddToCartForm {
my $self = shift;
my $session = $self->session;
my $i18n = WebGUI::International->new($session, 'Asset_Sku');
return
WebGUI::Form::formHeader($session, {action => $self->getUrl})
. WebGUI::Form::hidden( $session, {name => 'func', value => 'addToCart'})
. WebGUI::Form::submit( $session, {value => $i18n->get('add to cart')})
. WebGUI::Form::formFooter($session)
;
}
#-------------------------------------------------------------------
=head2 getCart ( )

View file

@ -138,6 +138,18 @@ sub definition {
#-------------------------------------------------------------------
=head2 getAddToCartForm
Returns an empty string, since the add to cart form is complex.
=cut
sub getAddToCartForm {
return '';
}
#-------------------------------------------------------------------
=head2 getClickDiscountText
returns the text to display the number of clicks purchasaed where discounts apply

View file

@ -92,6 +92,28 @@ sub definition {
}
#-------------------------------------------------------------------
=head2 getAddToCartForm ( )
Returns a form to add this Sku to the cart. Used when this Sku is part of
a shelf. Overrode master class to add price form.
=cut
sub getAddToCartForm {
my $self = shift;
my $session = $self->session;
my $i18n = WebGUI::International->new($session, 'Asset_Donation');
return
WebGUI::Form::formHeader($session, {action => $self->getUrl})
. WebGUI::Form::hidden( $session, {name => 'func', value => 'donate'})
. WebGUI::Form::float( $session, {name => 'price', defaultValue => $self->getPrice })
. WebGUI::Form::submit( $session, {value => $i18n->get('donate button')})
. WebGUI::Form::formFooter($session)
;
}
#-------------------------------------------------------------------
=head2 getConfiguredTitle

View file

@ -165,6 +165,26 @@ sub drawRelatedBadgeGroupsField {
}
#-------------------------------------------------------------------
=head2 getAddToCartForm
Returns a button to take the user to the view screen.
=cut
sub getAddToCartForm {
my $self = shift;
my $session = $self->session;
my $i18n = WebGUI::International->new($session, 'Asset_Sku');
return
WebGUI::Form::formHeader($session, {action => $self->getUrl})
. WebGUI::Form::hidden( $session, {name => 'func', value => 'view'})
. WebGUI::Form::submit( $session, {value => $i18n->get('see more')})
. WebGUI::Form::formFooter($session)
;
}
#-------------------------------------------------------------------
=head2 getConfiguredTitle

View file

@ -83,6 +83,26 @@ sub definition {
}
#-------------------------------------------------------------------
=head2 getAddToCartForm
Returns a button to take the user to the view screen.
=cut
sub getAddToCartForm {
my $self = shift;
my $session = $self->session;
my $i18n = WebGUI::International->new($session, 'Asset_Sku');
return
WebGUI::Form::formHeader($session, {action => $self->getUrl})
. WebGUI::Form::hidden( $session, {name => 'func', value => 'view'})
. WebGUI::Form::submit( $session, {value => $i18n->get('see more')})
. WebGUI::Form::formFooter($session)
;
}
#-------------------------------------------------------------------
=head2 getConfiguredTitle

View file

@ -229,6 +229,25 @@ sub drawRelatedRibbonsField {
#-------------------------------------------------------------------
=head2 getAddToCartForm
Returns a button to take the user to the view screen.
=cut
sub getAddToCartForm {
my $self = shift;
my $session = $self->session;
my $i18n = WebGUI::International->new($session, 'Asset_Sku');
return
WebGUI::Form::formHeader($session, {action => $self->getUrl})
. WebGUI::Form::hidden( $session, {name => 'func', value => 'view'})
. WebGUI::Form::submit( $session, {value => $i18n->get('see more')})
. WebGUI::Form::formFooter($session)
;}
#-------------------------------------------------------------------
=head2 getConfiguredTitle
Returns title + badgeholder name.

View file

@ -76,6 +76,26 @@ sub definition {
}
#-------------------------------------------------------------------
=head2 getAddToCartForm
Returns a button to take the user to the view screen.
=cut
sub getAddToCartForm {
my $self = shift;
my $session = $self->session;
my $i18n = WebGUI::International->new($session, 'Asset_Sku');
return
WebGUI::Form::formHeader($session, {action => $self->getUrl})
. WebGUI::Form::hidden( $session, {name => 'func', value => 'view'})
. WebGUI::Form::submit( $session, {value => $i18n->get('see more')})
. WebGUI::Form::formFooter($session)
;
}
#-------------------------------------------------------------------
=head2 getConfiguredTitle

View file

@ -240,6 +240,37 @@ sub duplicate {
}
#-------------------------------------------------------------------
=head2 getAddToCartForm ( )
Returns a form to add this Sku to the cart. Used when this Sku is part of
a shelf. Overrode master class to add variant dropdown.
=cut
sub getAddToCartForm {
my $self = shift;
my $session = $self->session;
my $i18n = WebGUI::International->new($session, 'Asset_Product');
my %variants = ();
tie %variants, 'Tie::IxHash';
foreach my $collateral ( @{ $self->getAllCollateral('variantsJSON')} ) {
$variants{$collateral->{variantId}} = join ", ", $collateral->{shortdesc}, sprintf('%.2f',$collateral->{price});
}
return
WebGUI::Form::formHeader($session, {action => $self->getUrl})
. WebGUI::Form::hidden( $session, {name => 'func', value => 'buy'})
. WebGUI::Form::selectBox( $session, {
name => 'vid',
options => \%variants,
value => [0],
})
. WebGUI::Form::submit( $session, {value => $i18n->get('add to cart')})
. WebGUI::Form::formFooter($session)
;
}
#-------------------------------------------------------------------
=head2 getAllCollateral ( tableName )

View file

@ -269,6 +269,27 @@ sub generateSubscriptionCodeBatch {
#-------------------------------------------------------------------
=head2 getAddToCartForm ( )
Returns a form to add this Sku to the cart. Used when this Sku is part of
a shelf. Override master class to add different form.
=cut
sub getAddToCartForm {
my $self = shift;
my $session = $self->session;
my $i18n = WebGUI::International->new($session, 'Asset_Subscription');
return
WebGUI::Form::formHeader($session, {action => $self->getUrl})
. WebGUI::Form::hidden( $session, {name => 'func', value => 'purchaseSubscription'})
. WebGUI::Form::submit( $session, {value => $i18n->get('purchase button')})
. WebGUI::Form::formFooter($session)
;
}
#-------------------------------------------------------------------
=head2 getAdminConsoleWithSubmenu ( )
Returns an admin console with management links added to the submenu.

View file

@ -308,10 +308,11 @@ sub view {
foreach my $id (@{$p->getPageData}) {
my $asset = WebGUI::Asset->newByDynamicClass($session, $id);
if (defined $asset) {
my $sku = $asset->get;
$sku->{url} = $asset->getUrl;
$sku->{thumbnailUrl} = $asset->getThumbnailUrl;
$sku->{price} = sprintf("%.2f", $asset->getPrice);
my $sku = $asset->get;
$sku->{url} = $asset->getUrl;
$sku->{thumbnailUrl} = $asset->getThumbnailUrl;
$sku->{price} = sprintf("%.2f", $asset->getPrice);
$sku->{addToCartForm} = $asset->getAddToCartForm;
push @skus, $sku;
}
else {

View file

@ -21,8 +21,11 @@ our $HELP = {
variables => [
{ name => "shelves" , required=>1},
{ name => "products" , required=>1, variables => [
{ name => "url",
description => 'product_url', },
{ name => "thumbnailUrl" },
{ name => "price" },
{ name => "addToCartForm" },
],
},
{ name => "templateId", description=>"shelf template help" },

View file

@ -33,6 +33,18 @@ our $I18N = {
context => q|a template variable|,
},
'product_url' => {
message => q|The URL to this sku.|,
lastUpdated => 0,
context => q|a template variable|,
},
'addToCartForm' => {
message => q|If this product supports it, the form to add this product to the cart. It will contain a submit button and all required form elements needed to add the product to the cart.|,
lastUpdated => 0,
context => q|a template variable|,
},
'shelves' => {
message => q|A loop containing the list of shelves that are children of this one in the asset tree. Each record in the loop contains all the properties of a shelf.|,
lastUpdated => 0,

View file

@ -93,6 +93,18 @@ our $I18N = {
context => q|help for tax rate override field|
},
'add to cart' => {
message => q|Add To Cart|,
lastUpdated => 0,
context => q|i18n label for the add to cart button|,
},
'see more' => {
message => q|See more|,
lastUpdated => 0,
context => q|alternate i18n label for the add to cart button|,
},
'Add a Variant' => {
message => q|Add a Variant|,
lastUpdated => 0,