[wellwell-devel] [SCM] Interchange wellwell catalog branch, master, updated. 79691f9b44a84e73e2e6453bd3d7672d4f5151c9

Stefan Hornburg racke at rt.icdevgroup.org
Thu Apr 9 09:29:12 UTC 2009


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Interchange wellwell catalog".

The branch, master has been updated
       via  79691f9b44a84e73e2e6453bd3d7672d4f5151c9 (commit)
      from  5739ea1abf39ffb3ef9a143c96578273c86ba64a (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 79691f9b44a84e73e2e6453bd3d7672d4f5151c9
Author: Stefan Hornburg (Racke) <racke at linuxia.de>
Date:   Thu Apr 9 11:28:46 2009 +0200

    provide for additional fields in wishlist_carts

-----------------------------------------------------------------------

Summary of changes and diff:
 plugins/wishlists/code/wishlist.tag |   26 ++++++++++++++++++++++++--
 plugins/wishlists/plugin.cfg        |    3 +++
 2 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/plugins/wishlists/code/wishlist.tag b/plugins/wishlists/code/wishlist.tag
index b51e138..9691c15 100644
--- a/plugins/wishlists/code/wishlist.tag
+++ b/plugins/wishlists/code/wishlist.tag
@@ -37,6 +37,14 @@ sub {
 		}
 	}
 
+	# determine fields to use for wishlists
+	my $i = 0;
+	my %product_fields;
+
+	for my $f (split(/\s*,\s*/, $Variable->{WISHLISTS_PRODUCTS_FIELDS})) {
+		$product_fields{$f} = $i++;
+	}	
+
 	if ($function eq 'create') {
 		my $pref;
 
@@ -63,7 +71,15 @@ sub {
 		}
 
 		# add product to wishlist
-		$Db{cart_products}->set_slice([$wishlist_code, $sku], {position => 0});
+		my %data = (position => 0);
+
+		for (keys %product_fields) {
+			if (exists $opt->{$_} && $opt->{$_} =~ /\S/) {
+				$data{$_} = $opt->{$_};
+			}
+		}
+
+		$Db{cart_products}->set_slice([$wishlist_code, $sku], \%data);
 		return 1;
 	}
 
@@ -78,7 +94,13 @@ sub {
 	}
 	elsif ($function eq 'list') {
 		# list products from wishlist
-		my $sql = qq{select sku,quantity from cart_products where cart = $wishlist_code order by position};
+		my $fields = '';
+
+		if (keys %product_fields) {
+			$fields = join(',', '', keys %product_fields);			
+		}
+
+		my $sql = qq{select sku$fields from cart_products where cart = $wishlist_code order by position};
 
 		return $Tag->query ({sql => $sql, list => 1, prefix => 'item',
 				body => $body});
diff --git a/plugins/wishlists/plugin.cfg b/plugins/wishlists/plugin.cfg
index bee6b3a..9aa9998 100644
--- a/plugins/wishlists/plugin.cfg
+++ b/plugins/wishlists/plugin.cfg
@@ -8,4 +8,7 @@ Database cart_products COMPOSITE_KEY cart,sku
 
 Variable WISHLISTS_DEFAULT_NAME wishlist
 
+# additional fields for cart_products table
+Variable WISHLISTS_PRODUCTS_FIELDS quantity
+
 ActionMap wishlists wishlists


hooks/post-receive
-- 
Interchange wellwell catalog



More information about the wellwell-devel mailing list