[wellwell-devel] [SCM] Interchange wellwell catalog branch, master, updated. 87a0533ff47cde677b3c33bfa720668d5474700e
Stefan Hornburg
racke at rt.icdevgroup.org
Thu Mar 18 08:01:22 UTC 2010
via 87a0533ff47cde677b3c33bfa720668d5474700e (commit)
from d7f0d42b6252506933a07337c8217d339bb2d344 (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 87a0533ff47cde677b3c33bfa720668d5474700e
Author: Rok RužiÄ <rruzic at gmail.com>
Date: Thu Mar 18 08:59:41 2010 +0100
combine cart items with matching sku and modifiers
-----------------------------------------------------------------------
Summary of changes and diff:
lib/WellWell/Cart.pm | 26 +++++++++++++++++++++++++-
1 files changed, 25 insertions(+), 1 deletions(-)
diff --git a/lib/WellWell/Cart.pm b/lib/WellWell/Cart.pm
index 53d99be..33904b7 100644
--- a/lib/WellWell/Cart.pm
+++ b/lib/WellWell/Cart.pm
@@ -78,7 +78,7 @@ sub cart_item {
sub cart_add {
my ($sku, $quantity, $opt) = @_;
- my ($itemref);
+ my ($itemref, $combref);
$itemref = cart_item($sku, $quantity, $opt);
@@ -92,6 +92,11 @@ sub cart_add {
Vend::Tags->error({name => $sku, set => $itemref->{error}, overwrite => 1});
return;
}
+
+ # see if we can combine this item into cart items
+ if (!$Vend::Cfg{SeparateItems} && ($combref = combine_items($itemref))){
+ return $combref;
+ }
# verify that number of items doesn't go out of bounds
if ($Vend::Cfg->{OrderLineLimit} && @$Vend::Items >= $Vend::Cfg->{OrderLineLimit}) {
@@ -211,4 +216,23 @@ sub cart_refresh_form_action {
return 1;
}
+sub combine_items {
+ my $item = shift;
+
+ ITEMS: for my $cartitem (@$Vend::Items){
+ if ($item->{'code'} eq $cartitem ->{'code'}){
+ if (ref($Vend::Cfg->{UseModifier}) eq 'ARRAY'){
+ for my $mod (@{$Vend::Cfg->{UseModifier}}){
+ next ITEMS unless($item->{$mod} eq $cartitem->{$mod});
+ }
+ }
+
+ $cartitem->{'quantity'} += $item->{'quantity'};
+ return $cartitem;
+ }
+ }
+
+ return;
+}
+
1;
hooks/post-receive
--
Interchange wellwell catalog
More information about the wellwell-devel
mailing list