[wellwell-devel] [wellwell] Refuse adding inactive items to the cart.
Stefan Hornburg
wellwell-devel at rt.icdevgroup.org
Tue Sep 28 09:36:10 UTC 2010
commit 32b24712ffd0bc032c832078a5d238368a434e8e
Author: Stefan Hornburg (Racke) <racke at linuxia.de>
Date: Tue Sep 28 11:25:55 2010 +0200
Refuse adding inactive items to the cart.
catalog.cfg | 1 +
lib/WellWell/Cart.pm | 7 +++++++
lib/WellWell/DatabaseCart.pm | 8 +++++---
3 files changed, 13 insertions(+), 3 deletions(-)
---
diff --git a/catalog.cfg b/catalog.cfg
index 586f7e9..6ee60d6 100644
--- a/catalog.cfg
+++ b/catalog.cfg
@@ -86,6 +86,7 @@ UserDB default crypt 0
# Cart
FormAction refresh cart_refresh
+AutoModifier inactive
# Routes and Orders
OrderCounter var/run/order.number
diff --git a/lib/WellWell/Cart.pm b/lib/WellWell/Cart.pm
index d85866c..ec038a5 100644
--- a/lib/WellWell/Cart.pm
+++ b/lib/WellWell/Cart.pm
@@ -104,6 +104,13 @@ sub cart_add {
return;
}
+ # now check whether the item is active
+ if (exists $itemref->{inactive}
+ && $itemref->{inactive}) {
+ Vend::Tags->error({name => $sku, set => 'Product has been discontinued', overwrite => 1});
+ return;
+ }
+
# see if we can combine this item into cart items
if ($subname = $Vend::Cfg->{SpecialSub}{separate_items}) {
$sub = $Vend::Cfg->{Sub}{$subname} || $Global::GlobalSub->{$subname};
diff --git a/lib/WellWell/DatabaseCart.pm b/lib/WellWell/DatabaseCart.pm
index 4ee4d68..5ac63d5 100644
--- a/lib/WellWell/DatabaseCart.pm
+++ b/lib/WellWell/DatabaseCart.pm
@@ -172,9 +172,11 @@ sub new {
sub add_item {
my ($self, $item) = @_;
- $self->{db_products}->set_slice([$self->{code}, $item->{code}], quantity => $item->{quantity},
- position => 0);
- $self->touch();
+ unless (exists $item->{inactive} && $item->{inactive}) {
+ $self->{db_products}->set_slice([$self->{code}, $item->{code}], quantity => $item->{quantity},
+ position => 0);
+ $self->touch();
+ }
}
sub delete_item {
More information about the wellwell-devel
mailing list