override addToCart in the Product Sku for doing inventory control
This commit is contained in:
parent
3ec94d50d8
commit
7dc385b362
1 changed files with 22 additions and 0 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue