[wellwell-devel] [SCM] Interchange wellwell catalog branch, master, updated. 4d5d840d56d5e9197f71bcffd7818371bc5fc874
Stefan Hornburg
racke at rt.icdevgroup.org
Thu Nov 19 23:57:13 UTC 2009
via 4d5d840d56d5e9197f71bcffd7818371bc5fc874 (commit)
via 1724cb71f85282a6fe61f3a7971b00fde1979e40 (commit)
via 4687377b52581edf7702e9e4fcafbecac358d849 (commit)
from f11093fb0c7fcf36375b104d64e999825cab0e54 (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 4d5d840d56d5e9197f71bcffd7818371bc5fc874
Merge: 1724cb71f85282a6fe61f3a7971b00fde1979e40 f11093fb0c7fcf36375b104d64e999825cab0e54
Author: Stefan Hornburg (Racke) <racke at linuxia.de>
Date: Fri Nov 20 00:56:54 2009 +0100
Merge branch 'master' of ssh://git.icdevgroup.org/var/git/wellwell
commit 1724cb71f85282a6fe61f3a7971b00fde1979e40
Author: Stefan Hornburg (Racke) <racke at linuxia.de>
Date: Fri Nov 20 00:54:05 2009 +0100
discount_gifts plugin added
commit 4687377b52581edf7702e9e4fcafbecac358d849
Author: Stefan Hornburg (Racke) <racke at linuxia.de>
Date: Fri Nov 20 00:07:10 2009 +0100
add passed parameters matching UseModifier to the item hash
-----------------------------------------------------------------------
Summary of changes and diff:
code/cart_add.tag | 6 ++++
.../code/discount_gifts_order_finalize.sub | 25 ++++++++++++++++++++
.../database/mysql/discount_gifts.sql | 9 +++++++
.../database/pgsql/discount_gifts.sql | 10 ++++++++
plugins/discount_gifts/discount_gifts.info | 3 ++
plugins/discount_gifts/plugin.cfg | 9 +++++++
6 files changed, 62 insertions(+), 0 deletions(-)
create mode 100644 plugins/discount_gifts/code/discount_gifts_order_finalize.sub
create mode 100644 plugins/discount_gifts/database/mysql/discount_gifts.sql
create mode 100644 plugins/discount_gifts/database/pgsql/discount_gifts.sql
create mode 100644 plugins/discount_gifts/discount_gifts.info
create mode 100644 plugins/discount_gifts/plugin.cfg
diff --git a/code/cart_add.tag b/code/cart_add.tag
index b0cea11..62bb590 100644
--- a/code/cart_add.tag
+++ b/code/cart_add.tag
@@ -20,6 +20,12 @@ sub {
$item{$_} = $opt->{$_} || $product_ref->{$_};
}
+ for (@{$Config->{UseModifier}}) {
+ if (exists $opt->{$_}) {
+ $item{$_} = $opt->{$_};
+ }
+ }
+
push(@$Items, \%item);
return;
diff --git a/plugins/discount_gifts/code/discount_gifts_order_finalize.sub b/plugins/discount_gifts/code/discount_gifts_order_finalize.sub
new file mode 100644
index 0000000..7180024
--- /dev/null
+++ b/plugins/discount_gifts/code/discount_gifts_order_finalize.sub
@@ -0,0 +1,25 @@
+Sub discount_gifts_order_finalize <<EOS
+sub {
+ my ($subtotal, $set);
+
+ $Tag->perl({tables => 'discount_gifts'});
+
+ # calculate subtotal
+ $subtotal = $Tag->subtotal({noformat => 1});
+
+ # current date
+ $today = $Tag->time({format => '%Y-%m-%d'});
+
+ # select discount gifts for the given subtotal
+ $set = $Db{discount_gifts}->query(qq{select sku,quantity from discount_gifts where $subtotal >= min_amount and '$today' >= start_date and '$today' <= end_date});
+
+ for (@$set) {
+ # adding discount gifts to the cart
+ $Tag->cart_add({sku => $_->[0],
+ quantity => $_->[1],
+ discount_gift => 1});
+ }
+
+ return;
+}
+EOS
diff --git a/plugins/discount_gifts/database/mysql/discount_gifts.sql b/plugins/discount_gifts/database/mysql/discount_gifts.sql
new file mode 100644
index 0000000..d93a41c
--- /dev/null
+++ b/plugins/discount_gifts/database/mysql/discount_gifts.sql
@@ -0,0 +1,9 @@
+create table discount_gifts (
+ code int unsigned NOT NULL auto_increment,
+ sku varchar(32) NOT NULL,
+ quantity integer NOT NULL DEFAULT 0,
+ start_date DATETIME,
+ end_date DATETIME,
+ min_amount numeric(11,2) NOT NULL DEFAULT 0,
+ PRIMARY KEY(code)
+);
diff --git a/plugins/discount_gifts/database/pgsql/discount_gifts.sql b/plugins/discount_gifts/database/pgsql/discount_gifts.sql
new file mode 100644
index 0000000..d160e6c
--- /dev/null
+++ b/plugins/discount_gifts/database/pgsql/discount_gifts.sql
@@ -0,0 +1,10 @@
+create table discount_gifts (
+ code serial NOT NULL,
+ sku varchar(32) NOT NULL,
+ quantity integer NOT NULL DEFAULT 0,
+ start_date TIMESTAMP,
+ end_date TIMESTAMP,
+ min_amount numeric(11,2) NOT NULL DEFAULT 0,
+ PRIMARY KEY(code)
+);
+
diff --git a/plugins/discount_gifts/discount_gifts.info b/plugins/discount_gifts/discount_gifts.info
new file mode 100644
index 0000000..148e86f
--- /dev/null
+++ b/plugins/discount_gifts/discount_gifts.info
@@ -0,0 +1,3 @@
+name = Discount Gifts
+version = 0.1
+author = Stefan Hornburg (Racke) <racke at linuxia.de>
diff --git a/plugins/discount_gifts/plugin.cfg b/plugins/discount_gifts/plugin.cfg
new file mode 100644
index 0000000..92cecb1
--- /dev/null
+++ b/plugins/discount_gifts/plugin.cfg
@@ -0,0 +1,9 @@
+Message Loading discount_gifts plugin.
+
+Variable CURPLUGIN discount_gifts
+include plugins/default.cfg
+
+Database discount_gifts AUTO_SEQUENCE discount_gifts_code_seq
+
+# used to mark item as discount gift
+UseModifier discount_gift
\ No newline at end of file
hooks/post-receive
--
Interchange wellwell catalog
More information about the wellwell-devel
mailing list