cart should be pretty much working at this point...now need to test and whatnot

This commit is contained in:
JT Smith 2008-02-26 02:12:31 +00:00
parent fa52bf1aef
commit d207994e90
4 changed files with 13 additions and 26 deletions

View file

@ -28,9 +28,6 @@ Adds an item to the cart. Returns the number of items now in the cart.
param: asset - the asset object to be added already
configured as needed
param: quantity - the number of this item that the
user wants
=head3 create
Creates a new cart object if there's not one already attached to the
@ -93,6 +90,7 @@ The following fields are needed to construct this object's table called
"cartItems".
Field Schema Description
itemId guid primary key
cartId guid The unique id for this cart.
assetId guid The assetId for this item.
options medium Text A json serialized hashref of any configuration data associated with this item so that it can be edited or whatnot.
@ -108,14 +106,11 @@ class.
Creates a new cart item object. Returns a reference to the object.
param: session - a reference to the current session
param: cartId - the unique id of the cart
param: cart - a reference to a cart
param: asset - A reference to the asset you wish to
create.
param: quantity - the quantity of sku to purchase
=head3 get
@ -128,6 +123,12 @@ rather than the hash reference
Returns an instanciated WebGUI::Asset::Sku object for this cart item.
=head3 incrementQuantity
Increment the amount in cart by one.
param: quantity - up it by more than one
=head3 new
Instanciates a cart item based upon a cartId and assetId.

View file

@ -61,6 +61,7 @@ sub migrateToNewCart {
index sessionId (sessionId)
)");
$session->db->write("create table cartItems (
itemId varchar(22) binary not null primary key,
cartId varchar(22) binary not null,
assetId varchar(22) binary not null,
options mediumtext,

View file

@ -67,12 +67,7 @@ sub create {
return $class->new($session, $cartId) if (defined $cartId);
my $cartId = $session->id->generate;
$session->db->write('insert into cart (cartId, sessionId) values (?,?)', [$cartId, $session->getId]);
bless my $self, $class;
register $self;
my $id = id $self;
$session{ $id } = $session;
$properties{ $id } = {cartId=>$cartId, sessionId=>$session->getId};
return $self;
return $class->new($session, $cartId);
}
#-------------------------------------------------------------------

View file

@ -121,24 +121,14 @@ sub incrementQuantity {
my ($self, $quantity) = @_;
$quantity ||= 1;
my $id = $self;
if ($self->get("quantity") + $quantity > $self->getSku->getMaxAllowedInCart) {
croak "Cannot have that many in cart.";
}
$properties{$id}{quantity} += $quantity;
$cart->session->db->setRow("cartItems","itemId", $properties{$id});
}
#-------------------------------------------------------------------
=head2 isAtMaxQuantity ( )
Returns a boolean indicating whether the item is already at max quantity in the cart.
=cut
sub isAtMaxQuantity {
my ($self) = @_;
}
#-------------------------------------------------------------------
=head2 new ( session, cart, itemId )