override addToCart in the Product Sku for doing inventory control

This commit is contained in:
Colin Kuskie 2008-05-11 04:34:13 +00:00
parent 3ec94d50d8
commit 7dc385b362

View file

@ -56,6 +56,28 @@ sub addRevision {
return $newSelf;
}
#-------------------------------------------------------------------
=head2 addToCart ( variant )
Override/extend Sku's addToCart method to handle inventory control.
=head3 variant
A hashref of variant information for the variant of the Product
that is being added to the cart. Adding the variant to the
cart decrements the quantity by 1.
=cut
sub addToCart {
my $self = shift;
my $variant = shift;
$variant->{quantity} -= 1;
$self->setCollateral('variantsJSON', 'vid', $variant);
$self->SUPER::addToCart($variant);
}
#-------------------------------------------------------------------
sub definition {
my $class = shift;