Name

assign — assign overrides for salestax, shipping, handling and subtotal

ATTRIBUTES

Attribute Pos. Req. Default Description
salestax None Override for [salestax].
shipping None Override for [shipping]. Applies to [total-cost] only if mv_shipmode is set.
handling None Override for [handling]. Applies to [total-cost] only if mv_handling is set.
subtotal None Override for [subtotal].
credit None Credit assignment.
clear No Clear all assignments?
interpolate     0 interpolate output?
hide     0 Hide the tag return value?

DESCRIPTION

The [assign] tag allows you to set direct, fixed values for some of the parts of the checkout process, instead of deriving the values by performing calculations, as it would happen in the normal course of action.

The value assignment is persistent for the duration of the user session, unless you clear it explicitly.

The clear option will cancel all active assignments. To clear an individual assignment, set its value to an empty string. (Beware, a specification such as handling=0 actually sets handling costs to zero, it does not clear the assignment. To clear the assignment, you must use handling="").

Rounding

Overrides for [shipping] and [handling] are rounded to locale-specific number of fractional digits. Overrides for [subtotal] and [salestax] are used verbatim.

BEHAVIOR

This tag does not appear to be affected by, or affect, the rest of Interchange.

EXAMPLES

Example: Setting shipping costs to 4.99

[assign shipping=4.99]


Example: Setting handling costs to 0

[assign handling=0]


Example: Clearing the assignment for salestax

[assign salestax=""]


Example: Clearing all assignments

[assign clear=1]


NOTES

Assignments affect only the values returned by the corresponding tags. Other behavior (such as currency formatting) is, of course, not affected.

Assigning any value other than a number (or an empty string, when clearing assignments), will result in an error being reported and the assignment for the "subsystem" in question cleared.

An assignment is allowed to be a negative number.

You cannot directly assign a "total cost" amount — it will always be the sum of all assignment keys.

AVAILABILITY

assign is available in Interchange versions:

4.6.0-5.9.0 (git-head)

SOURCE

Interchange 5.9.0:

Source: code/SystemTag/assign.coretag
Lines: 49


# Copyright 2002-2007 Interchange Development Group and others
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: assign.coretag,v 1.5 2007-03-30 23:40:49 pajamian Exp $

UserTag assign              addAttr
UserTag assign              PosNumber    0
UserTag assign              Version      $Revision: 1.5 $
UserTag assign              Routine      <<EOR
my %_assignable = (qw/
      salestax  1
      shipping  1
      handling  1
      subtotal  1
      credit    1  
      /);
sub {
my ($opt) = @_;
if($opt->{clear}) {
  delete $Vend::Session->{assigned};
  return;
}
$Vend::Session->{assigned} ||= {};
for(keys %$opt) {
  next unless $_assignable{$_};
  my $value = $opt->{$_};
  $value =~ s/^\s+//;
  $value =~ s/\s+$//;
  if($value =~ /^-?\d+\.?\d*$/) {
    $Vend::Session->{assigned}{$_} = $value;
  }
  else {
          if ($value) {
        logError(
          "Attempted assign of non-numeric '%s' to %s. Deleted.",
          $value,
          $_,
        );
          }
    delete $Vend::Session->{assigned}{$_};
  }
}
return;
}
EOR

AUTHORS

Interchange Development Group

SEE ALSO

shipping(7ic), salestax(7ic)

DocBook! Interchange!