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
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue