[wellwell-devel] [SCM] Interchange wellwell catalog branch, master, updated. 50d4a58277e5cd624740b73e2b72a1689f1b5303
Stefan Hornburg
racke at rt.icdevgroup.org
Tue Apr 13 14:30:30 UTC 2010
via 50d4a58277e5cd624740b73e2b72a1689f1b5303 (commit)
from fd9b72fc9b2c0a6f90cd08b0d214edc39825eda1 (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 50d4a58277e5cd624740b73e2b72a1689f1b5303
Author: Stefan Hornburg (Racke) <racke at linuxia.de>
Date: Tue Apr 13 12:57:03 2010 +0200
min_count option added to carts function
-----------------------------------------------------------------------
Summary of changes and diff:
plugins/wishlists/code/wishlist.tag | 39 ++++++++++++++++++++++++++++++++--
1 files changed, 36 insertions(+), 3 deletions(-)
diff --git a/plugins/wishlists/code/wishlist.tag b/plugins/wishlists/code/wishlist.tag
index 8a79678..4ce4322 100644
--- a/plugins/wishlists/code/wishlist.tag
+++ b/plugins/wishlists/code/wishlist.tag
@@ -17,15 +17,48 @@ sub {
$Tag->perl({tables => 'products carts cart_products'});
if ($function eq 'carts') {
- my @carts;
+ my (@carts, @cart_fields, $field_str, $group_str, $have_name, $query);
+
+ if ($opt->{passed}) {
+ @cart_fields = qw/code name/;
+ $have_name = 1;
+ }
+ else {
+ @cart_fields = qw/code/;
+ }
+
+ if ($opt->{min_count}) {
+ # complex query needed
+ $field_str = join(',', map {"C.$_"} @cart_fields);
+
+ if ($have_name) {
+ $group_str = $field_str;
+ }
+ else {
+ $group_str = "$field_str,C.name";
+ }
+
+ $query = qq{select $field_str, count(CP.cart) from carts C left join cart_products CP on (C.code = CP.cart) where C.uid = %s and type = '%s' group by $group_str order by C.name};
+ }
+ else {
+ $field_str = join(',', @cart_fields);
+ $query = qq{select $field_str from carts where uid = '%s' and type = '%s' order by name};
+ }
+
+ $set = $Db{carts}->query($query, $Session->{username}, $type);
+
+ if ($opt->{min_count}) {
+ # filter out carts below minimum count
+ my $pos = @cart_fields;
+
+ @$set = grep {$_->[$pos] >= $opt->{min_count}} @$set;
+ }
if ($opt->{passed}) {
# produce string suitable for [display passed=]
- $set = $Db{carts}->query(qq{select code,name from carts where uid = $Session->{username} and type = '%s' order by name}, $type);
@carts = map {"$_->[0]=$_->[1]"} @$set;
}
else {
- $set = $Db{carts}->query(qq{select code from carts where uid = $Session->{username} and type = '%s' order by name}, $type);
@carts = map {$_->[0]} @$set;
}
hooks/post-receive
--
Interchange wellwell catalog
More information about the wellwell-devel
mailing list