diff --git a/lib/WebGUI/Asset/Sku/Product.pm b/lib/WebGUI/Asset/Sku/Product.pm index 24ea8ab1c..e660ecf23 100644 --- a/lib/WebGUI/Asset/Sku/Product.pm +++ b/lib/WebGUI/Asset/Sku/Product.pm @@ -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;