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:
JT Smith 2008-05-24 23:27:30 +00:00
parent e3061a1606
commit 57c85fde5a
18 changed files with 895 additions and 43 deletions

View file

@ -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().