[wellwell-devel] [wellwell] Organize coupons in the session by coupon number.
Stefan Hornburg
wellwell-devel at rt.icdevgroup.org
Wed Jul 21 10:52:05 UTC 2010
commit 7c9b2326f26851f4d2a5f2a499e1f4b5a06c4fe7
Author: Stefan Hornburg (Racke) <racke at linuxia.de>
Date: Wed Jul 21 11:42:11 2010 +0200
Organize coupons in the session by coupon number.
Add DISCOUNT_TOTAL placeholder for [coupons display].
lib/WellWell/Coupon.pm | 11 +++++++----
1 files changed, 7 insertions(+), 4 deletions(-)
---
diff --git a/lib/WellWell/Coupon.pm b/lib/WellWell/Coupon.pm
index 57453c8..796a136 100644
--- a/lib/WellWell/Coupon.pm
+++ b/lib/WellWell/Coupon.pm
@@ -64,6 +64,9 @@ sub coupons {
for (@{$repo->[0]}) {
my %hash = %{$repo->[1]->{$_}};
+ $hash{coupon_number} = $_;
+ $hash{discount_total} = Vend::Tags->subtotal({name => 'main', noformat => 1, nodiscount => 1})
+ - Vend::Tags->subtotal('main', 1);
push (@out, Vend::Tags->uc_attr_list({hash => \%hash, body => $body}));
}
@@ -129,7 +132,7 @@ sub apply_discounts {
Vend::Tags->discount({code => 'ALL_ITEMS', body => '$s * ' . $factor});
$self->{discount} = $value;
- $Vend::Session->{coupons}->[1]->{$self->{code}}->{discount} = $value;
+ $Vend::Session->{coupons}->[1]->{$self->{coupon_number}}->{discount} = $value;
}
}
}
@@ -212,9 +215,9 @@ sub log {
$Vend::Session->{coupons} ||= [[], {}];
- push (@{$Vend::Session->{coupons}->[0]}, $self->{code});
- $Vend::Session->{coupons}->[1]->{$self->{code}} = {coupon_number => $self->{coupon_number},
- valid_to => $self->{valid_to}};
+ push (@{$Vend::Session->{coupons}->[0]}, $self->{coupon_number});
+ $Vend::Session->{coupons}->[1]->{$self->{coupon_number}} = {code => $self->{code},
+ valid_to => $self->{valid_to}};
return $code;
}
More information about the wellwell-devel
mailing list