1 # Copyright 2002-2007 Interchange Development Group and others
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version. See the LICENSE file for details.
8 # $Id: discount.coretag,v 1.7 2007-03-30 23:40:49 pajamian Exp $
10 UserTag discount Order code
11 UserTag discount AddAttr
12 UserTag discount attrAlias space discount_space
13 UserTag discount hasEndTag
14 UserTag discount PosNumber 1
15 UserTag discount Version $Revision: 1.7 $
16 UserTag discount Routine <<EOR
18 # Sets the value of a discount field
20 my($code, $opt, $value) = @_;
29 and $Vend::Session->{discount_space}
30 and $Vend::Session->{discount}
31 and $Vend::DiscountSpaceName)) {
33 = $Vend::Session->{discount}
34 = $Vend::Session->{discount_space}{ $Vend::DiscountSpaceName = 'main' }
35 ||= ($Vend::Session->{discount} || {});
39 if ($Vend::Cfg->{DiscountSpacesOn} and $dspace = $opt->{discount_space}) {
40 $dspace = $Vend::Session->{discount_space}{$dspace} ||= {};
43 $dspace = $::Discounts;
46 if($opt->{subtract}) {
48 my \$tmp = \$s - $opt->{subtract};
49 \$tmp = 0 if \$tmp < 0;
53 elsif ($opt->{level}) {
55 return (\$s * \$q) if \$q < $opt->{level};
61 $dspace->{$code} = $value;
62 delete $dspace->{$code}
63 unless defined $value and $value;