Interchange

CVS log for interchange/code/SystemTag/discount.coretag

[BACK] Up to [Local Repository] / interchange / code / SystemTag

Request diff between arbitrary revisions


Keyword substitution: kv
Default branch: MAIN


Revision 1.6.2.1: download - view: text, markup, annotated - select for diffs
Sat Mar 31 00:20:09 2007 UTC (21 months, 1 week ago) by pajamian
Branches: STABLE_5_4-branch
CVS tags: REL_5_4_3
Diff to: previous 1.6: preferred, colored; next MAIN 1.7: preferred, colored
Changes since revision 1.6: +9 -4 lines
Fix incorrect license in headers GPL v2 -> GPL v2 "or later".  Update copyrights.

Revision 1.7: download - view: text, markup, annotated - select for diffs
Fri Mar 30 23:40:49 2007 UTC (21 months, 1 week ago) by pajamian
Branches: MAIN
CVS tags: STABLE_5_6-root, STABLE_5_6-branch, REL_5_7_1, REL_5_6_1, REL_5_5_3, REL_5_5_2, REL_5_5_1, HEAD, DEB_5_6_1_2, DEB_5_5_1_1_1, DEB_5_5_1
Diff to: previous 1.6: preferred, colored
Changes since revision 1.6: +9 -4 lines
Fix incorrect license in headers GPL v2 -> GPL v2 "or later".  Update copyrights.

Revision 1.6: download - view: text, markup, annotated - select for diffs
Thu Apr 7 22:51:32 2005 UTC (3 years, 9 months ago) by jon
Branches: MAIN
CVS tags: STABLE_5_4-root, REL_5_4_2, REL_5_4_1, REL_5_4_0, REL_5_3_3, REL_5_3_2, DEB_5_3_0_20051028_1, DEB_5_3_0_20051004_1
Branch point for: STABLE_5_4-branch
Diff to: previous 1.5: preferred, colored
Changes since revision 1.5: +10 -10 lines
Patch from Ethan Rowe <ethan@endpoint.com>, which I've been sitting on
for far too long. His comments:

Discount-space rework according to agreements reached between involved
core team members; modified initialization logic and configuration such
that discount spaces do not make an impact on page processing for catalogs
that do not explicitly make use of the feature. Changes include:

DiscountSpacesOn -- boolean catalog configuration directive. This is
FALSE by default. When set to true, a dispatch routine is added
to the (relatively new) dispatch routine stack, to be evaluated
per page process prior to autoloads; this routine initializes the
current discount space to 'main', and then checks all CGI variables
specified in the DiscountSpaceVar configuration array in the event
that an alternate discount space has been specified via CGI variables.
When DiscountSpacesOn is FALSE, *all* discount space functions become
a no-op; attempts to specify an alternate discount space will have no
effect, and will result in an error message in the catalog's error log.

DiscountSpaceVar -- array catalog configuration directive, with a default
entry of 'mv_discount_space'; the members of this array are treated as
names of CGI variables to check per page process, such that a CGI variable
can be used to specify the discount space to use for that page process
in a manner akin to values space ('mv_values_space') or named shopping
cart ('mv_cartname'). The CGI variables will *not* be checked unless
DiscountSpacesOn is true. While default behavior of 'mv_discount_space'
is likely to suffice for most purposes, people can tie the discount space
to other things, such as the cart, by including other variable names in
this array (for instance, 'mv_cartname' would tie the discount space to
the cart name, which could be convenient in some situations).

A new global object has been introduced: $::Discounts. This will always
point to the current discount hash; changing the discount space via
CGI variables or the [discount-space] tag will update $::Discounts.
Furthermore, a new Safe object has been introduced for accessing the
current discount space in [perl] and [calc] blocks: $Discounts.

Any code that works directly with the $Vend::Session->{discount} hash
should be updated to work with the $::Discounts variable (in global
space) and the $Discounts variable (in Safe space such as [perl] and
[calc]). Care has been taken to maintain backwards compatibility,
and working directly with the {discount} session member will generally
not cause problems (changing the discount space will in fact change the
hash to which $Vend::Session->{discount} points), except in the case of
reassigning the hash (i.e., $Session->{discount} = { 'SOMEITEM' => ' %s *
0.80 ' }); reassigning the hash will break the $::Discounts reference and
result in unpredictable behavior for the remainder of the page process.
Therefore, it is strongly advised that all such code be updated at some
point to use the new objects. Furthermore, any actions such as clearing
the discounts should be done by dereferencing rather than assigning a
new hashref.

Thus:
%$Discounts = ();
and not:
$Discounts = {};

Furthermore, you can clear the discount space via:
[discount-space name=some_spacename clear=1]

The current discount space name can be checked via:
[discount-space current=1]

Sessions: to maintain backwards compatibility, sessions continue to use a
{discount} member. However, at session initialization, all sessions will
receive a {discount_space}{main} member, and {discount} will point to it.
The session read process is essentially unchanged, with the exception of
a minor assignment in which $::Discounts is initialized to point to the
{discount} member. The modification to discount-spaces was driven in
part to reduce the number of assignments necessary at session read time,
and this new implementation is a reflection of that.

For the future, it may be worthwhile to revise the logic to eliminate
the {discount} session member entirely, and simply expect all code to
work directly through the $::Discounts/$Discounts variables. This would
allow some slight adjustments to the implementation of the discount space
initialization and switching logic, making it slightly more efficient
and certainly cleaner.

Revision 1.5: download - view: text, markup, annotated - select for diffs
Wed Feb 9 13:39:42 2005 UTC (3 years, 10 months ago) by docelic
Branches: MAIN
Diff to: previous 1.4: preferred, colored
Changes since revision 1.4: +2 -1 lines
Header/license fix or Version update+minor formatting fix, or both

Revision 1.4: download - view: text, markup, annotated - select for diffs
Tue Jan 25 01:02:58 2005 UTC (3 years, 11 months ago) by jon
Branches: MAIN
Diff to: previous 1.3: preferred, colored
Changes since revision 1.3: +27 -5 lines
New discount-space functionality by Ethan Rowe <ethan@endpoint.com>.
His notes follow.

Implements discount namespaces, in a manner consistent with the
values-space functionality. The [discount-space] usertag can be used
to change the current discount namespace, causing all subsequent
discount-related tags and calculations to operate from that particular
namespace. Usage:

[discount-space name=<space>]
Changes the current discount namespace to <space>.

[discount-space current=1]
Returns the name of the current namespace.

[discount-space name=<space> clear=1]
Clears all discount information from the specified namespace.

The discount space is initialized, per page process, in a manner
similar to values-space; if a CGI value exists under the variable name
"mv_discount_space", the discount space will be initialized to that
value. Furthermore, a catalog-level variable MV_DISCOUNT_SPACE can be
used to specify the name of an additional CGI variable to check in this
manner. When MV_DISCOUNT_SPACE is defined, it has higher precedence than
mv_discount_space for determining the initial namespace.

The discount-space logic is designed to integrate well with the cart. The
default discount spacename is "main". Setting the catalog variable
MV_DISCOUNT_SPACE to 'mv_cartname' allows the current discount namespace
to match the current cart when the current cart is set via CGI variables.

The discount namespaces are stored in the session at
$Vend::Session->{discount_space}{<spacename>}. Note that, for backwards
compatibility, the default space is always at $Vend::Session->{discount},
and that this will always serve as the master for he "main"
namespace such that $Vend::Session->{discount_space}{main}
= $Vend::Session->{discount}. Reassigning the hashref
for $Vend::Session->{discount_space}{<spacename>}
or $Vend::Session->{discount} can take Interchange internal
variables out of sync, and is thus discouraged (just as performing
a $Session->{scratch} = {} mid-page could cause odd behavior. Use
[discount-space name=<space> clear=1] instead, or assign to the
dereferenced hash (%{$Vend::Session->{discount}} = ()).

For further support, a discount_space parameter has been added to each
of the following tags; these tags all can be affected by discounts,
either in the calculation of a discount, a taxable sum, or an item
price (passing a discount namespace to these tags via the discount_space
parameter will only affect the current discount space within the context
of the tag itself):

[discount]
[fly-tax] (Also added named cart support to this tag in the process)
[item-list] (namespace specified will be used throughout the tag and its subtags)
[salestax]
[subtotal]
[total_cost]

EXAMPLES:

Set the current discount space to the default (which is 'main')
[discount-space]
OR
[discount-space main]

Set the current discount space to space "alt_discount"
[discount name=alt_discount]

Clear discount namespace "garbage"
[discount-space name=garbage clear=1]

Show the current discount namespace
[discount-space current=1]

Use the discount namespace "other" for this loop through the cart
[item-list discount_space=other]
...
[/item-list]

Revision 1.3: download - view: text, markup, annotated - select for diffs
Thu Jan 6 17:19:50 2005 UTC (4 years ago) by docelic
Branches: MAIN
Diff to: previous 1.2: preferred, colored
Changes since revision 1.2: +4 -0 lines

* Header/license fix

Revision 1.2: download - view: text, markup, annotated - select for diffs
Wed May 7 01:07:28 2003 UTC (5 years, 8 months ago) by racke
Branches: MAIN
CVS tags: STABLE_5_2-root, STABLE_5_2-branch, STABLE_5_0-root, STABLE_5_0-branch, REL_5_2_1, REL_5_2_0, REL_5_1_1, REL_5_1_0, REL_5_0_2, REL_5_0_1, REL_5_0_0_RC2, REL_5_0_0_RC1, REL_5_0_0, REL_4_9_9, REL_4_9_8, MANIFEST, DEB_5_2_1_1, DEB_5_0_0_2, DEB_4_9_8_20031014_1, DEB_4_9_8_20031010_1, DEB_4_9_8_20030911_1, DEB_4_9_8_20030706_1, DEB_4_9_8_2
Diff to: previous 1.1: preferred, colored
Changes since revision 1.1: +0 -1 lines
removal of InvalidateCache attribute

Revision 1.1.2.1: download - view: text, markup, annotated - select for diffs
Sat Jan 25 22:20:32 2003 UTC (5 years, 11 months ago) by racke
Branches: LINUXIA
Diff to: previous 1.1: preferred, colored; next MAIN 1.2: preferred, colored
Changes since revision 1.1: +0 -0 lines
updated LINUXIA branch to 4.9 sources in order to use it as testbed again

Revision 1.1: download - view: text, markup, annotated - select for diffs
Tue Jan 29 05:52:38 2002 UTC (6 years, 11 months ago) by mheins
Branches: MAIN
CVS tags: REL_4_9_6, REL_4_9_5, REL_4_9_4, REL_4_9_2, REL_4_9_1
Branch point for: LINUXIA
	* The great tag breakout!

	* Almost all tags are now UserTag definitions. The only exceptions
	  are:

		and bounce goto if label or unless

    * New TagDir directive (default is VENDROOT/code) sets the
	  directory (or directories) which are searched for code definitions
	  set by UserTag and CodeDef.

	* New TagGroup directive establishes groups of ITL tags which can
	  be included.

	  	TagGroup :crufty "banner default ecml html_table onfly sql"

	  The default groups include :core, which contains all of the
	  ITL tags defined in 4.8/early 4.9. The groups are defined
	  in $Vend::Cfg::StdTags and can be undefined if desired
	  with "TagGroup :group".

	* New TagInclude directive allows inclusion of tags (or groups
	  of tags). If a tag is defined as a core tag (with a .coretag
	  or .tag or .ct extension) and is not included, it will not
	  be compiled and placed in the tag map. This is for all catalogs,
	  so if *any* catalog uses a tag it must be included.

	  Examples:

		# Include the base tags
	  	TagInclude :core

		# Not the commerce tags
		TagInclude !:commerce

		# But make sure item-list is included even though
		# it is in :commerce
		TagInclude item-list

		## Double negatives are honored
		TagGroup    :foo "bar !baz buz"
		## With the group above, the below is equivalent
		## to TagInclude !bar baz !buz
		TagInclude !:foo

    * New CodeDef directive allows the setting of filters,
	  order checks, FormAction, ActionMap, ItemAction,
	  and LocaleChange.

			## filters
			CodeDef  mixedcase Filter
			CodeDef  mixedcase Routine <<EOR
			sub {
				my $val = shift;
				## [filter mixedcase]mixed case[/filter]
				## outputs "MiXeD CaSe"
				$val =~ s/(.)(.)/\u$1\l$2/g;
				return $val;
			}
			EOR

			## order checks
			CodeDef  mixedcase OrderCheck
			CodeDef  foo  Routine <<EOR
			sub {
				my ($ref, $var, $val) = @_;
				return (1,$var) if $val eq 'bar';
				return (0,$var, "foo must be bar");
			}
			EOR

	   All work in catalog.cfg; LocaleChange and ItemAction are not
	   global. FormAction, ActionMap, and ItemAction directives
	   are equivalent to their CodeDef equivalents.

Diff request

This form allows you to request diffs between any two revisions of a file. You may select a symbolic revision name using the selection box or you may type in a numeric name using the type-in text box.

Log view options

Interchange CVSweb <info@icdevgroup.org>