changed the name of getCartBySession to newBySession
created the CartItemCount and MiniCart macros added help for MinCart, Cart, Address Book, and Edit Address templates
This commit is contained in:
parent
e3061a1606
commit
57c85fde5a
18 changed files with 895 additions and 43 deletions
Binary file not shown.
|
|
@ -686,6 +686,8 @@ sub migrateToNewCart {
|
|||
$session->db->write("drop table shoppingCart");
|
||||
$session->setting->add('shopCartTemplateId','aIpCmr9Hi__vgdZnDTz1jw');
|
||||
$session->config->addToHash("macros","ViewCart","ViewCart");
|
||||
$session->config->addToHash("macros","CartItemCount","CartItemCount");
|
||||
$session->config->addToHash("macros","MiniCart","MiniCart");
|
||||
}
|
||||
|
||||
#-------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -333,7 +333,7 @@
|
|||
"#" : "Hash_userId",
|
||||
"/" : "Slash_gatewayUrl",
|
||||
"@" : "At_username",
|
||||
"ViewCart" : "ViewCart",
|
||||
"a" : "a_account",
|
||||
"AOIHits" : "AOIHits",
|
||||
"AOIRank" : "AOIRank",
|
||||
"AdminBar" : "AdminBar",
|
||||
|
|
@ -341,8 +341,11 @@
|
|||
"AdminToggle" : "AdminToggle",
|
||||
"AdSpace" : "AdSpace",
|
||||
"AssetProxy" : "AssetProxy",
|
||||
"c" : "c_companyName",
|
||||
"CanEditText" : "CanEditText",
|
||||
"CartItemCount" : "CartItemCount",
|
||||
"D" : "D_date",
|
||||
"e" : "e_companyEmail",
|
||||
"EditableToggle" : "EditableToggle",
|
||||
"Extras" : "Extras",
|
||||
"FetchMimeType" : "FetchMimeType",
|
||||
|
|
@ -355,20 +358,19 @@
|
|||
"L" : "L_loginBox",
|
||||
"LastModified" : "LastModified",
|
||||
"LoginToggle" : "LoginToggle",
|
||||
"MiniCart" : "MiniCart",
|
||||
"Page" : "Page",
|
||||
"PageTitle" : "PageTitle",
|
||||
"PageUrl" : "PageUrl",
|
||||
"r" : "r_printable",
|
||||
"RandomAssetProxy" : "RandomAssetProxy",
|
||||
"RandomThread" : "RandomThread",
|
||||
"RootTitle" : "RootTitle",
|
||||
"Spacer" : "Spacer",
|
||||
"Thumbnail" : "Thumbnail",
|
||||
"User" : "User",
|
||||
"a" : "a_account",
|
||||
"c" : "c_companyName",
|
||||
"e" : "e_companyEmail",
|
||||
"r" : "r_printable",
|
||||
"u" : "u_companyUrl"
|
||||
"User" : "User",
|
||||
"ViewCart" : "ViewCart",
|
||||
},
|
||||
|
||||
#Specify any LDAP aliases for synchronizing user profiles to LDAP
|
||||
|
|
|
|||
|
|
@ -169,7 +169,7 @@ Returns a reference to the current session's cart.
|
|||
|
||||
sub getCart {
|
||||
my $self = shift;
|
||||
return WebGUI::Shop::Cart->getCartBySession($self->session);
|
||||
return WebGUI::Shop::Cart->newBySession($self->session);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -1448,7 +1448,7 @@ sub view {
|
|||
'variant_controls' => $segment,
|
||||
'variant_sku' => $collateral->{varSku},
|
||||
'variant_title' => $collateral->{shortdesc},
|
||||
'variant_price' => $collateral->{price},
|
||||
'variant_price' => sprintf("%.2f", $collateral->{price}),
|
||||
'variant_weight' => $collateral->{weight},
|
||||
'variant_quantity' => $collateral->{quantity},
|
||||
});
|
||||
|
|
|
|||
|
|
@ -411,7 +411,7 @@ sub www_buildBadge {
|
|||
manageEventMetaFieldsUrl => $self->getUrl('func=manageEventMetaFields'),
|
||||
);
|
||||
my @otherBadges =();
|
||||
my $cart = WebGUI::Shop::Cart->getCartBySession($session);
|
||||
my $cart = WebGUI::Shop::Cart->newBySession($session);
|
||||
foreach my $item (@{$cart->getItems}) {
|
||||
my $id = $item->get('options')->{badgeId};
|
||||
next if ($id eq $badgeId);
|
||||
|
|
@ -755,7 +755,7 @@ sub www_getRegistrantAsJson {
|
|||
}
|
||||
|
||||
# see what's in the cart
|
||||
my $cart = WebGUI::Shop::Cart->getCartBySession($session);
|
||||
my $cart = WebGUI::Shop::Cart->newBySession($session);
|
||||
foreach my $item (@{$cart->getItems}) {
|
||||
# not related to this badge, so skip it
|
||||
next unless $item->get('options')->{badgeId} eq $badgeId;
|
||||
|
|
@ -1478,7 +1478,7 @@ sub www_removeItemFromBadge {
|
|||
my $session = $self->session;
|
||||
return $session->privilege->insufficient() unless $self->canView;
|
||||
my $form = $session->form;
|
||||
my $cart = WebGUI::Shop::Cart->getCartBySession($session);
|
||||
my $cart = WebGUI::Shop::Cart->newBySession($session);
|
||||
my $item = $cart->getItem($form->get('itemId'));
|
||||
$item->remove;
|
||||
return $self->www_getRegistrantAsJson();
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ sub www_cart {
|
|||
my $session = shift;
|
||||
my $output = undef;
|
||||
my $method = "www_". ( $session->form->get("method") || "view");
|
||||
my $cart = WebGUI::Shop::Cart->getCartBySession($session);
|
||||
my $cart = WebGUI::Shop::Cart->newBySession($session);
|
||||
if ($cart->can($method)) {
|
||||
$output = $cart->$method();
|
||||
}
|
||||
|
|
|
|||
382
lib/WebGUI/Help/Shop.pm
Normal file
382
lib/WebGUI/Help/Shop.pm
Normal file
|
|
@ -0,0 +1,382 @@
|
|||
package WebGUI::Help::Shop;
|
||||
|
||||
use strict;
|
||||
|
||||
|
||||
our $HELP = {
|
||||
'minicart template' => {
|
||||
title => 'minicart template',
|
||||
body => 'minicart template help',
|
||||
isa => [],
|
||||
fields => [],
|
||||
variables => [
|
||||
{
|
||||
name => "items",
|
||||
description => "items loop help",
|
||||
required => 1,
|
||||
variables => [
|
||||
{
|
||||
name => "name",
|
||||
description => "item name help",
|
||||
required => 1,
|
||||
},
|
||||
{
|
||||
name => "quantity",
|
||||
description => "quantity help",
|
||||
},
|
||||
{
|
||||
name => "price",
|
||||
description => "price help",
|
||||
},
|
||||
{
|
||||
name => "url",
|
||||
description => "item url help",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name => "totalPrice",
|
||||
description => "totalPrice help",
|
||||
},
|
||||
{
|
||||
name => "totalItems",
|
||||
description => "totalItems help",
|
||||
},
|
||||
],
|
||||
related => [
|
||||
{
|
||||
tag => 'cart template',
|
||||
namespace => 'Shop',
|
||||
},
|
||||
],
|
||||
},
|
||||
'cart template' => {
|
||||
title => 'cart template',
|
||||
body => 'cart template help',
|
||||
isa => [],
|
||||
fields => [],
|
||||
variables => [
|
||||
{
|
||||
name => "items",
|
||||
description => "items loop help",
|
||||
required => 1,
|
||||
variables => [
|
||||
{
|
||||
name => "configuredTitle",
|
||||
description => "configuredTitle help",
|
||||
required => 1,
|
||||
},
|
||||
{
|
||||
name => "quantity",
|
||||
description => "quantity help",
|
||||
},
|
||||
{
|
||||
name => "dateAdded",
|
||||
description => "dateAdded help",
|
||||
},
|
||||
{
|
||||
name => "url",
|
||||
description => "item url help",
|
||||
},
|
||||
{
|
||||
name => "quantityField",
|
||||
description => "quantityField help",
|
||||
required => 1,
|
||||
},
|
||||
{
|
||||
name => "isUnique",
|
||||
description => "isUnique help",
|
||||
},
|
||||
{
|
||||
name => "isShippable",
|
||||
description => "isShippable help",
|
||||
},
|
||||
{
|
||||
name => "extendedPrice",
|
||||
description => "extendedPrice help",
|
||||
},
|
||||
{
|
||||
name => "price",
|
||||
description => "price help",
|
||||
},
|
||||
{
|
||||
name => "removeButton",
|
||||
description => "removeButton help",
|
||||
required => 1,
|
||||
},
|
||||
{
|
||||
name => "shipToButton",
|
||||
description => "item shipToButton help",
|
||||
},
|
||||
{
|
||||
name => "shippingAddress",
|
||||
description => "shippingAddress help",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name => "error",
|
||||
description => "error help",
|
||||
required => 1,
|
||||
},
|
||||
{
|
||||
name => "formHeader",
|
||||
description => "formHeader help",
|
||||
required => 1,
|
||||
},
|
||||
{
|
||||
name => "formFooter",
|
||||
description => "formFooter help",
|
||||
required => 1,
|
||||
},
|
||||
{
|
||||
name => "checkoutButton",
|
||||
description => "checkoutButton help",
|
||||
required => 1,
|
||||
},
|
||||
{
|
||||
name => "updateButton",
|
||||
description => "updateButton help",
|
||||
required => 1,
|
||||
},
|
||||
{
|
||||
name => "continueShoppingButton",
|
||||
description => "continueShoppingButton help",
|
||||
},
|
||||
{
|
||||
name => "chooseShippingButton",
|
||||
description => "chooseShippingButton help",
|
||||
required => 1,
|
||||
},
|
||||
{
|
||||
name => "shipToButton",
|
||||
description => "shipToButton help",
|
||||
},
|
||||
{
|
||||
name => "subtotalPrice",
|
||||
description => "subtotalPrice help",
|
||||
},
|
||||
{
|
||||
name => "shippingPrice",
|
||||
description => "shippingPrice help",
|
||||
},
|
||||
{
|
||||
name => "tax",
|
||||
description => "tax help",
|
||||
},
|
||||
{
|
||||
name => "hasShippingAddress",
|
||||
description => "hasShippingAddress help",
|
||||
},
|
||||
{
|
||||
name => "shippingAddress",
|
||||
description => "shippingAddress help",
|
||||
},
|
||||
{
|
||||
name => "shippingOptions",
|
||||
description => "shippingOptions help",
|
||||
required => 1,
|
||||
},
|
||||
{
|
||||
name => "totalPrice",
|
||||
description => "totalPrice help",
|
||||
required => 1,
|
||||
},
|
||||
{
|
||||
name => "inShopCreditAvailable",
|
||||
description => "inShopCreditAvailable help",
|
||||
},
|
||||
{
|
||||
name => "inShopCreditDeduction",
|
||||
description => "inShopCreditDeduction help",
|
||||
},
|
||||
],
|
||||
related => [
|
||||
{
|
||||
tag => 'minicart template',
|
||||
namespace => 'Shop',
|
||||
},
|
||||
{
|
||||
tag => 'address book template',
|
||||
namespace => 'Shop',
|
||||
},
|
||||
],
|
||||
},
|
||||
'address book template' => {
|
||||
title => 'address book template',
|
||||
body => 'address book template help',
|
||||
isa => [],
|
||||
fields => [],
|
||||
variables => [
|
||||
{
|
||||
name => "addresses",
|
||||
description => "addresses loop help",
|
||||
required => 1,
|
||||
variables => [
|
||||
{
|
||||
name => "address",
|
||||
description => "address help",
|
||||
required => 1,
|
||||
},
|
||||
{
|
||||
name => "editButton",
|
||||
description => "editButton help",
|
||||
required => 1,
|
||||
},
|
||||
{
|
||||
name => "deleteButton",
|
||||
description => "deleteButton help",
|
||||
required => 1,
|
||||
},
|
||||
{
|
||||
name => "useButton",
|
||||
description => "useButton help",
|
||||
required => 1,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name => "addButton",
|
||||
description => "addButton help",
|
||||
required => 1,
|
||||
},
|
||||
],
|
||||
related => [
|
||||
{
|
||||
tag => 'cart template',
|
||||
namespace => 'Shop',
|
||||
},
|
||||
{
|
||||
tag => 'edit address template',
|
||||
namespace => 'Shop',
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
'edit address template' => {
|
||||
title => 'edit address template',
|
||||
body => 'edit address template help',
|
||||
isa => [],
|
||||
fields => [],
|
||||
variables => [
|
||||
{
|
||||
name => "address1",
|
||||
description => "address1 help",
|
||||
},
|
||||
{
|
||||
name => "address2",
|
||||
description => "address2 help",
|
||||
},
|
||||
{
|
||||
name => "address3",
|
||||
description => "address3 help",
|
||||
},
|
||||
{
|
||||
name => "state",
|
||||
description => "state help",
|
||||
},
|
||||
{
|
||||
name => "city",
|
||||
description => "city help",
|
||||
},
|
||||
{
|
||||
name => "label",
|
||||
description => "label help",
|
||||
},
|
||||
{
|
||||
name => "name",
|
||||
description => "name help",
|
||||
},
|
||||
{
|
||||
name => "country",
|
||||
description => "country help",
|
||||
},
|
||||
{
|
||||
name => "code",
|
||||
description => "code help",
|
||||
},
|
||||
{
|
||||
name => "phoneNumber",
|
||||
description => "phoneNumber help",
|
||||
},
|
||||
{
|
||||
name => "error",
|
||||
description => "error help",
|
||||
required => 1,
|
||||
},
|
||||
{
|
||||
name => "formHeader",
|
||||
description => "formHeader help",
|
||||
required => 1,
|
||||
},
|
||||
{
|
||||
name => "formFooter",
|
||||
description => "formFooter help",
|
||||
required => 1,
|
||||
},
|
||||
{
|
||||
name => "saveButton",
|
||||
description => "saveButton help",
|
||||
required => 1,
|
||||
},
|
||||
{
|
||||
name => "address1Field",
|
||||
description => "address1Field help",
|
||||
required => 1,
|
||||
},
|
||||
{
|
||||
name => "address2Field",
|
||||
description => "address2Field help",
|
||||
required => 1,
|
||||
},
|
||||
{
|
||||
name => "address3Field",
|
||||
description => "address3Field help",
|
||||
required => 1,
|
||||
},
|
||||
{
|
||||
name => "labelField",
|
||||
description => "address labelField help",
|
||||
required => 1,
|
||||
},
|
||||
{
|
||||
name => "nameField",
|
||||
description => "addres nameField help",
|
||||
required => 1,
|
||||
},
|
||||
{
|
||||
name => "cityField",
|
||||
description => "cityField help",
|
||||
required => 1,
|
||||
},
|
||||
{
|
||||
name => "stateField",
|
||||
description => "stateField help",
|
||||
required => 1,
|
||||
},
|
||||
{
|
||||
name => "countryField",
|
||||
description => "countryField help",
|
||||
required => 1,
|
||||
},
|
||||
{
|
||||
name => "codeField",
|
||||
description => "codeField help",
|
||||
required => 1,
|
||||
},
|
||||
{
|
||||
name => "phoneNumberField",
|
||||
description => "phoneNumberField help",
|
||||
required => 1,
|
||||
},
|
||||
],
|
||||
related => [
|
||||
{
|
||||
tag => 'address book template',
|
||||
namespace => 'Shop',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
1;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package WebGUI::Help::Asset_FlatDiscount;
|
||||
package WebGUI::Help::Skeleton;
|
||||
|
||||
use strict;
|
||||
|
||||
|
|
|
|||
44
lib/WebGUI/Macro/CartItemCount.pm
Normal file
44
lib/WebGUI/Macro/CartItemCount.pm
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
package WebGUI::Macro::CartItemCount;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2008 Plain Black Corporation.
|
||||
#-------------------------------------------------------------------
|
||||
# Please read the legal notices (docs/legal.txt) and the license
|
||||
# (docs/license.txt) that came with this distribution before using
|
||||
# this software.
|
||||
#-------------------------------------------------------------------
|
||||
# http://www.plainblack.com info@plainblack.com
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
use strict;
|
||||
use WebGUI::Shop::Cart;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Package WebGUI::Macro::CartItemCount
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Returns an integer of the number of items currently in the cart.
|
||||
|
||||
=head2 process( $session )
|
||||
|
||||
Renders the macro.
|
||||
|
||||
=cut
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub process {
|
||||
my ($session) = @_;
|
||||
my $cart = WebGUI::Shop::Cart->newBySession($session);
|
||||
my $count = 0;
|
||||
foreach my $item (@{$cart->getItems}) {
|
||||
$count += $item->get('quantity');
|
||||
}
|
||||
return $count;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
|
||||
68
lib/WebGUI/Macro/MiniCart.pm
Normal file
68
lib/WebGUI/Macro/MiniCart.pm
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
package WebGUI::Macro::MiniCart;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2008 Plain Black Corporation.
|
||||
#-------------------------------------------------------------------
|
||||
# Please read the legal notices (docs/legal.txt) and the license
|
||||
# (docs/license.txt) that came with this distribution before using
|
||||
# this software.
|
||||
#-------------------------------------------------------------------
|
||||
# http://www.plainblack.com info@plainblack.com
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
use strict;
|
||||
use WebGUI::Asset::Template;
|
||||
use WebGUI::Shop::Cart;
|
||||
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Package WebGUI::Macro::MiniCart
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Displays a miniature view of the shopping cart.
|
||||
|
||||
=head2 process( $session, [templateId])
|
||||
|
||||
Renders the macro.
|
||||
|
||||
=head3 templateId
|
||||
|
||||
Pass in a template id other than the default.
|
||||
|
||||
=cut
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub process {
|
||||
my ($session, $templateId) = @_;
|
||||
my $cart = WebGUI::Shop::Cart->newBySession($session);
|
||||
my @items = ();
|
||||
my $totalItems = 0;
|
||||
my $totalPrice = 0;
|
||||
foreach my $item (@{$cart->getItems}) {
|
||||
my $sku = $item->getSku;
|
||||
my $price = $sku->getPrice;
|
||||
my $quantity = $item->get('quantity');
|
||||
push @items, {
|
||||
name => $item->get('configuredTitle'),
|
||||
quantity => $quantity,
|
||||
price => $price,
|
||||
url => $sku->getUrl('shop=cart;method=viewItem;itemId='.$item->getId),
|
||||
};
|
||||
$totalItems += $quantity;
|
||||
$totalPrice += $quantity * $price;
|
||||
}
|
||||
my %var = (
|
||||
items => \@items,
|
||||
totalPrice => sprintf(".2f",$totalPrice),
|
||||
totalItems => $totalItems,
|
||||
);
|
||||
my $template = WebGUI::Asset::Template->new($session, $templateId || 'EBlxJpZQ9o-8VBOaGQbChA');
|
||||
return $template->process(\%var);
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
|
||||
|
|
@ -27,7 +27,7 @@ Renders the macro.
|
|||
|
||||
=head3 linktext
|
||||
|
||||
Defaults to "View Cart".
|
||||
Defaults to "View Cart". "linkonly" will return only the URL to the cart.
|
||||
|
||||
=cut
|
||||
|
||||
|
|
@ -35,10 +35,16 @@ Defaults to "View Cart".
|
|||
#-------------------------------------------------------------------
|
||||
sub process {
|
||||
my ($session, $text) = @_;
|
||||
unless ($text) {
|
||||
my $url = $session->url->page("shop=cart");
|
||||
if ($text eq "linkonly") {
|
||||
return $url;
|
||||
}
|
||||
elsif ($text) {
|
||||
# us text specified
|
||||
}
|
||||
else {
|
||||
$text = WebGUI::International->new($session,"Shop")->get("view cart");
|
||||
}
|
||||
my $url = $session->url->page("shop=cart");
|
||||
return '<a href="'.$url.'"><img src="'.$session->url->extras('/macro/ViewCart/cart.gif').'" alt="'.$text.'" style="border: 0px;vertical-align: middle;" /></a> <a href="'.$url.'">'.$text.'</a>';
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -272,28 +272,6 @@ sub getAddressBook {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getCartBySession ( session )
|
||||
|
||||
Class method that figures out if the user has a cart in their session. If they do it returns it. If they don't it creates it and returns it.
|
||||
|
||||
=head3 session
|
||||
|
||||
A reference to the current session.
|
||||
|
||||
=cut
|
||||
|
||||
sub getCartBySession {
|
||||
my ($class, $session) = @_;
|
||||
unless (defined $session && $session->isa("WebGUI::Session")) {
|
||||
WebGUI::Error::InvalidObject->throw(expected=>"WebGUI::Session", got=>(ref $session), error=>"Need a session.");
|
||||
}
|
||||
my $cartId = $session->db->quickScalar("select cartId from cart where sessionId=?",[$session->getId]);
|
||||
return $class->new($session, $cartId) if (defined $cartId);
|
||||
return $class->create($session);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getId ()
|
||||
|
||||
Returns the unique id for this cart.
|
||||
|
|
@ -460,6 +438,28 @@ sub new {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 newBySession ( session )
|
||||
|
||||
Class method that figures out if the user has a cart in their session. If they do it returns it. If they don't it creates it and returns it.
|
||||
|
||||
=head3 session
|
||||
|
||||
A reference to the current session.
|
||||
|
||||
=cut
|
||||
|
||||
sub newBySession {
|
||||
my ($class, $session) = @_;
|
||||
unless (defined $session && $session->isa("WebGUI::Session")) {
|
||||
WebGUI::Error::InvalidObject->throw(expected=>"WebGUI::Session", got=>(ref $session), error=>"Need a session.");
|
||||
}
|
||||
my $cartId = $session->db->quickScalar("select cartId from cart where sessionId=?",[$session->getId]);
|
||||
return $class->new($session, $cartId) if (defined $cartId);
|
||||
return $class->create($session);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 onCompletePurchase ()
|
||||
|
||||
Deletes all the items in the cart without calling $item->remove() on them which would affect inventory levels. See also delete() and empty().
|
||||
|
|
|
|||
|
|
@ -356,7 +356,7 @@ sub www_selectPaymentGateway {
|
|||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
|
||||
my $cart = WebGUI::Shop::Cart->getCartBySession( $session );
|
||||
my $cart = WebGUI::Shop::Cart->newBySession( $session );
|
||||
my $i18n = WebGUI::International->new( $session, 'Shop' );
|
||||
|
||||
# Make sure the user is logged in.
|
||||
|
|
|
|||
|
|
@ -281,7 +281,7 @@ Returns the WebGUI::Shop::Cart object for the current session.
|
|||
sub getCart {
|
||||
my $self = shift;
|
||||
|
||||
my $cart = WebGUI::Shop::Cart->getCartBySession( $self->session );
|
||||
my $cart = WebGUI::Shop::Cart->newBySession( $self->session );
|
||||
|
||||
return $cart;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,354 @@ our $I18N = {
|
|||
context => q|a link label|,
|
||||
},
|
||||
|
||||
'minicart template' => {
|
||||
message => q|MiniCart Template|,
|
||||
lastUpdated => 0,
|
||||
context => q|a help title|,
|
||||
},
|
||||
|
||||
'address book template' => {
|
||||
message => q|Address Book Template|,
|
||||
lastUpdated => 0,
|
||||
context => q|a help title|,
|
||||
},
|
||||
|
||||
'edit address template' => {
|
||||
message => q|Edit Address Template|,
|
||||
lastUpdated => 0,
|
||||
context => q|a help title|,
|
||||
},
|
||||
|
||||
'cart template' => {
|
||||
message => q|Cart Template|,
|
||||
lastUpdated => 0,
|
||||
context => q|a help title|,
|
||||
},
|
||||
|
||||
'address book template' => {
|
||||
message => q|Address Book Template|,
|
||||
lastUpdated => 0,
|
||||
context => q|a help title|,
|
||||
},
|
||||
|
||||
'quantity help' => {
|
||||
message => q|The number of this item that is purchased.|,
|
||||
lastUpdated => 0,
|
||||
context => q|a help description|,
|
||||
},
|
||||
|
||||
'item name help' => {
|
||||
message => q|The name or title of the product.|,
|
||||
lastUpdated => 0,
|
||||
context => q|a help description|,
|
||||
},
|
||||
|
||||
'price help' => {
|
||||
message => q|The amount this items costs to purchase.|,
|
||||
lastUpdated => 0,
|
||||
context => q|a help description|,
|
||||
},
|
||||
|
||||
'configuredTitle help' => {
|
||||
message => q|The name of the item as configured for purchase.|,
|
||||
lastUpdated => 0,
|
||||
context => q|a help description|,
|
||||
},
|
||||
|
||||
'dateAdded help' => {
|
||||
message => q|The date and time this item was added to the cart.|,
|
||||
lastUpdated => 0,
|
||||
context => q|a help description|,
|
||||
},
|
||||
|
||||
'isUnique help' => {
|
||||
message => q|A condition indicating whether this item is unique and therefore can only have a quantity of 1.|,
|
||||
lastUpdated => 0,
|
||||
context => q|a help description|,
|
||||
},
|
||||
|
||||
'quantityField help' => {
|
||||
message => q|The field where the user may specify the quantity of the item they wish to purchase.|,
|
||||
lastUpdated => 0,
|
||||
context => q|a help description|,
|
||||
},
|
||||
|
||||
'isShippable help' => {
|
||||
message => q|A condition indicating whether the item can have a shipping address attached to it.|,
|
||||
lastUpdated => 0,
|
||||
context => q|a help description|,
|
||||
},
|
||||
|
||||
'extendedPrice help' => {
|
||||
message => q|The result of price multipled by quantity.|,
|
||||
lastUpdated => 0,
|
||||
context => q|a help description|,
|
||||
},
|
||||
|
||||
'removeButton help' => {
|
||||
message => q|Clicking this button will remove the item from the cart.|,
|
||||
lastUpdated => 0,
|
||||
context => q|a help description|,
|
||||
},
|
||||
|
||||
'item shipToButton help' => {
|
||||
message => q|Clicking this button will set an alternate address as the destination of this item.|,
|
||||
lastUpdated => 0,
|
||||
context => q|a help description|,
|
||||
},
|
||||
|
||||
'shippingAddress help' => {
|
||||
message => q|The HTML formatted address to ship to.|,
|
||||
lastUpdated => 0,
|
||||
context => q|a help description|,
|
||||
},
|
||||
|
||||
'error help' => {
|
||||
message => q|If there are any problems the error message will be displayed here.|,
|
||||
lastUpdated => 0,
|
||||
context => q|a help description|,
|
||||
},
|
||||
|
||||
'formHeader help' => {
|
||||
message => q|The top of the form.|,
|
||||
lastUpdated => 0,
|
||||
context => q|a help description|,
|
||||
},
|
||||
|
||||
'formFooter help' => {
|
||||
message => q|The bottom of the form.|,
|
||||
lastUpdated => 0,
|
||||
context => q|a help description|,
|
||||
},
|
||||
|
||||
'checkoutButton help' => {
|
||||
message => q|The button the user pushes to choose a payment method.|,
|
||||
lastUpdated => 0,
|
||||
context => q|a help description|,
|
||||
},
|
||||
|
||||
'continueShoppingButton help' => {
|
||||
message => q|Clicking this button will take the user back to the site.|,
|
||||
lastUpdated => 0,
|
||||
context => q|a help description|,
|
||||
},
|
||||
|
||||
'updateButton help' => {
|
||||
message => q|Clicking this button will apply the changes you made to the cart and recalculate all the prices.|,
|
||||
lastUpdated => 0,
|
||||
context => q|a help description|,
|
||||
},
|
||||
|
||||
'chooseShippingButton help' => {
|
||||
message => q|Clicking this button will let the user pick a shipping address from the address book.|,
|
||||
lastUpdated => 0,
|
||||
context => q|a help description|,
|
||||
},
|
||||
|
||||
'shipToButton help' => {
|
||||
message => q|Does the same as the chooseShippingButton.|,
|
||||
lastUpdated => 0,
|
||||
context => q|a help description|,
|
||||
},
|
||||
|
||||
'subtotalPrice help' => {
|
||||
message => q|The price of all the items in the cart.|,
|
||||
lastUpdated => 0,
|
||||
context => q|a help description|,
|
||||
},
|
||||
|
||||
'shippingPrice help' => {
|
||||
message => q|The price of shipping on all the items in the cart.|,
|
||||
lastUpdated => 0,
|
||||
context => q|a help description|,
|
||||
},
|
||||
|
||||
'tax help' => {
|
||||
message => q|The price of tax on all the items in the cart.|,
|
||||
lastUpdated => 0,
|
||||
context => q|a help description|,
|
||||
},
|
||||
|
||||
'hasShippingAddress help' => {
|
||||
message => q|A condition indicating whether the the user has already specified a shipping address. Shipping address is always required in order to calculate taxes.|,
|
||||
lastUpdated => 0,
|
||||
context => q|a help description|,
|
||||
},
|
||||
|
||||
'shippingOptions help' => {
|
||||
message => q|A select list containing all the configured shipping options for this order.|,
|
||||
lastUpdated => 0,
|
||||
context => q|a help description|,
|
||||
},
|
||||
|
||||
'inShopCreditAvailable help' => {
|
||||
message => q|The amount of in-shop credit the user has.|,
|
||||
lastUpdated => 0,
|
||||
context => q|a help description|,
|
||||
},
|
||||
|
||||
'inShopCreditDeduction help' => {
|
||||
message => q|The amount of in-shop credit that has been applied to this order.|,
|
||||
lastUpdated => 0,
|
||||
context => q|a help description|,
|
||||
},
|
||||
|
||||
'totalPrice help' => {
|
||||
message => q|The total checkout price of the cart as it stands currently.|,
|
||||
lastUpdated => 0,
|
||||
context => q|a help description|,
|
||||
},
|
||||
|
||||
'totalItems help' => {
|
||||
message => q|The total number of items in the cart.|,
|
||||
lastUpdated => 0,
|
||||
context => q|a help description|,
|
||||
},
|
||||
|
||||
'item url help' => {
|
||||
message => q|The url to view this item as configured.|,
|
||||
lastUpdated => 0,
|
||||
context => q|a help description|,
|
||||
},
|
||||
|
||||
'items loop help' => {
|
||||
message => q|A loop containing the variables of each item in the cart.|,
|
||||
lastUpdated => 0,
|
||||
context => q|a help description|,
|
||||
},
|
||||
|
||||
'minicart template help' => {
|
||||
message => q|The following variables are available in the template for the MiniCart macro.|,
|
||||
lastUpdated => 0,
|
||||
context => q|a help description|,
|
||||
},
|
||||
|
||||
'cart template help' => {
|
||||
message => q|The following variables are available in the shopping cart template.|,
|
||||
lastUpdated => 0,
|
||||
context => q|a help description|,
|
||||
},
|
||||
|
||||
'address book template help' => {
|
||||
message => q|The following variables are available for templating the Address Book.|,
|
||||
lastUpdated => 0,
|
||||
context => q|a help description|,
|
||||
},
|
||||
|
||||
'address book template help' => {
|
||||
message => q|The following variables are available from in the address book template.|,
|
||||
lastUpdated => 0,
|
||||
context => q|a help description|,
|
||||
},
|
||||
|
||||
'address loop help' => {
|
||||
message => q|A loop containing the list of addresses in this book and their management tools.|,
|
||||
lastUpdated => 0,
|
||||
context => q|a help description|,
|
||||
},
|
||||
|
||||
'address help' => {
|
||||
message => q|An HTML formatted address.|,
|
||||
lastUpdated => 0,
|
||||
context => q|a help description|,
|
||||
},
|
||||
|
||||
'editButton help' => {
|
||||
message => q|A button that will allow the user to edit an existing address.|,
|
||||
lastUpdated => 0,
|
||||
context => q|a help description|,
|
||||
},
|
||||
|
||||
'deleteButton help' => {
|
||||
message => q|A button that will allow the user to delete an existing address.|,
|
||||
lastUpdated => 0,
|
||||
context => q|a help description|,
|
||||
},
|
||||
|
||||
'useButton help' => {
|
||||
message => q|A button that will allow the user to select an existing address for use on a form.|,
|
||||
lastUpdated => 0,
|
||||
context => q|a help description|,
|
||||
},
|
||||
|
||||
'addButton help' => {
|
||||
message => q|A button that will allow the user to add a new address.|,
|
||||
lastUpdated => 0,
|
||||
context => q|a help description|,
|
||||
},
|
||||
|
||||
'edit address template help' => {
|
||||
message => q|The following variables are available in the edit address template.|,
|
||||
lastUpdated => 0,
|
||||
context => q|a help description|,
|
||||
},
|
||||
|
||||
'saveButton help' => {
|
||||
message => q|The default save button for the form.|,
|
||||
lastUpdated => 0,
|
||||
context => q|a help description|,
|
||||
},
|
||||
|
||||
'address1Field help' => {
|
||||
message => q|The field for the main address line.|,
|
||||
lastUpdated => 0,
|
||||
context => q|a help description|,
|
||||
},
|
||||
|
||||
'address2Field help' => {
|
||||
message => q|The field for the secondary address line.|,
|
||||
lastUpdated => 0,
|
||||
context => q|a help description|,
|
||||
},
|
||||
|
||||
'address3Field help' => {
|
||||
message => q|The field for the tertiary address line.|,
|
||||
lastUpdated => 0,
|
||||
context => q|a help description|,
|
||||
},
|
||||
|
||||
'address labelField help' => {
|
||||
message => q|A field to contain the address label like 'home' or 'work'.|,
|
||||
lastUpdated => 0,
|
||||
context => q|a help description|,
|
||||
},
|
||||
|
||||
'address nameField help' => {
|
||||
message => q|A field to contain the name of the person/company for this address.|,
|
||||
lastUpdated => 0,
|
||||
context => q|a help description|,
|
||||
},
|
||||
|
||||
'cityField help' => {
|
||||
message => q|A field to contain the city for this address.|,
|
||||
lastUpdated => 0,
|
||||
context => q|a help description|,
|
||||
},
|
||||
|
||||
'stateField help' => {
|
||||
message => q|A field to contain the state or province for this address.|,
|
||||
lastUpdated => 0,
|
||||
context => q|a help description|,
|
||||
},
|
||||
|
||||
'countryField help' => {
|
||||
message => q|A field to contain the country for this address.|,
|
||||
lastUpdated => 0,
|
||||
context => q|a help description|,
|
||||
},
|
||||
|
||||
'codeField help' => {
|
||||
message => q|A field to contain the zip code or postal code for this address.|,
|
||||
lastUpdated => 0,
|
||||
context => q|a help description|,
|
||||
},
|
||||
|
||||
'phoneNumberField help' => {
|
||||
message => q|A field to contain the phone number for this address.|,
|
||||
lastUpdated => 0,
|
||||
context => q|a help description|,
|
||||
},
|
||||
|
||||
'view cart' => {
|
||||
message => q|View Cart|,
|
||||
lastUpdated => 0,
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ plan tests => 20; # Increment this number for each test you create
|
|||
#----------------------------------------------------------------------------
|
||||
# put your tests here
|
||||
|
||||
throws_deeply ( sub { my $cart = WebGUI::Shop::Cart->getCartBySession(); },
|
||||
throws_deeply ( sub { my $cart = WebGUI::Shop::Cart->newBySession(); },
|
||||
'WebGUI::Error::InvalidObject',
|
||||
{
|
||||
error => 'Need a session.',
|
||||
|
|
@ -47,7 +47,7 @@ throws_deeply ( sub { my $cart = WebGUI::Shop::Cart->getCartBySession(); },
|
|||
'newBySession takes an exception to not giving it a session variable'
|
||||
);
|
||||
|
||||
my $cart = WebGUI::Shop::Cart->getCartBySession($session);
|
||||
my $cart = WebGUI::Shop::Cart->newBySession($session);
|
||||
|
||||
isa_ok($cart, "WebGUI::Shop::Cart");
|
||||
isa_ok($cart->session, "WebGUI::Session");
|
||||
|
|
|
|||
|
|
@ -540,7 +540,7 @@ SKIP: {
|
|||
|
||||
##Build a cart, add some Donation SKUs to it. Set one to be taxable.
|
||||
|
||||
my $cart = WebGUI::Shop::Cart->getCartBySession($session);
|
||||
my $cart = WebGUI::Shop::Cart->newBySession($session);
|
||||
|
||||
is($taxer->calculate($cart), 0, 'calculate returns 0 if there is no shippingAddressId in the cart');
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue