[wellwell-devel] [SCM] Interchange wellwell catalog branch, master, updated. b4468731b10bf46a40c8a443c4e2c2074d789cb9
Stefan Hornburg
racke at rt.icdevgroup.org
Tue Jan 19 17:15:42 UTC 2010
via b4468731b10bf46a40c8a443c4e2c2074d789cb9 (commit)
from 9d1b65051fb23a088ff8e0a50d0732e48f7821fa (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit b4468731b10bf46a40c8a443c4e2c2074d789cb9
Author: Stefan Hornburg (Racke) <racke at linuxia.de>
Date: Tue Jan 19 12:15:00 2010 -0500
adjust hook names because we deal with individual items
provide hooks for item deletion and modification
-----------------------------------------------------------------------
Summary of changes and diff:
lib/WellWell/Cart.pm | 30 +++++++++++++++++++++---------
1 files changed, 21 insertions(+), 9 deletions(-)
diff --git a/lib/WellWell/Cart.pm b/lib/WellWell/Cart.pm
index 59e960e..1c4ce95 100644
--- a/lib/WellWell/Cart.pm
+++ b/lib/WellWell/Cart.pm
@@ -77,7 +77,7 @@ sub cart_add {
$itemref = cart_item($sku, $quantity, $opt);
- WellWell::Core::hooks('run', 'cart_add', $itemref);
+ WellWell::Core::hooks('run', 'cart_item_add', $itemref);
push(@$Vend::Items, $itemref);
@@ -85,15 +85,17 @@ sub cart_add {
}
sub cart_refresh {
- my ($cart, $new_cart, $line, $quantity);
-
+ my ($cart, $new_cart, $itemref, $quantity);
+
$cart = $Vend::Items;
$new_cart = [];
return 1 unless defined $CGI::values{"quantity0"};
foreach my $i (0 .. $#$cart) {
- $line = $cart->[$i];
+ my $modref = {};
+
+ $itemref = $cart->[$i];
$quantity = $CGI::values{"quantity$i"};
# trim quantity
@@ -101,23 +103,33 @@ sub cart_refresh {
$quantity =~ s/\s+$//;
if (defined $quantity) {
- if ($quantity =~ /^(\d+)$/ && $quantity != $line->{quantity}) {
+ if ($quantity =~ /^(\d+)$/ && $quantity != $itemref->{quantity}) {
if ($quantity == 0) {
# deleting the item by omission
+ WellWell::Core::hooks('run', 'cart_item_delete', $itemref);
next;
}
- $line->{quantity} = $quantity;
+ $modref->{quantity} = $quantity;
}
}
# checking whether any modifier changed
for (@{$Vend::Cfg->{UseModifier}}) {
- if (exists $CGI::values{"$_$i"}) {
- $line->{$_} = $CGI::values{"$_$i"};
+ if (exists $CGI::values{"$_$i"}
+ && $CGI::values{"$_$i"} ne $itemref->{$_}) {
+ $modref->{$_} = $CGI::values{"$_$i"};
+ }
+ }
+
+ if (keys %$modref) {
+ WellWell::Core::hooks('run', 'cart_item_modify', $itemref, $modref);
+
+ for (keys %$modref) {
+ $itemref->{$_} = $modref->{$_};
}
}
- push (@$new_cart, $line);
+ push (@$new_cart, $itemref);
}
@$cart = @$new_cart;
hooks/post-receive
--
Interchange wellwell catalog
More information about the wellwell-devel
mailing list