shipping — display shipping cost for items in electronic cart
| Attribute | Pos. | Req. | Default | Description |
|---|---|---|---|---|
| mode | Yes | shipping mode | ||
| possible | list available shipping modes | |||
| resolve | resolve shipping mode | |||
| check_validity | 0 | whether to check shipping mode is valid or not | ||
| widget | ||||
| label | ||||
| handling | ||||
| free | text for free shipping | |||
| reset_modes | ||||
| add | ||||
| file | ||||
| default | ||||
| output_options | ||||
| country_var |
country
|
name of country variable in value namespace | ||
| state_var |
state
|
name of state variable in value namespace | ||
| noformat | ||||
| display | symbol | Display currency as symbol, text or not at all? | ||
| interpolate | 0 | interpolate output? | ||
| hide | 0 | Hide the tag return value? |
Without any parameters, [shipping] displays the shipping
cost for the items in the cart.
[shipping possible=1]
This can be used to display custom parameters for the currently available
shipping modes with the [shipping-desc] tag:
[loop list="[shipping possible=1]"] Shipping Mode: [shipping-desc mode="[loop-code]"] Processing time: [shipping-desc mode="[loop-code]" key=p_time] Shipping time: [shipping-desc mode="[loop-code]" key=s_time] Cost: [shipping mode="[loop-code]"] [/loop]
The availability of shipping modes depends on shipping parameters, usually
the shipping country. [shipping check_validity=1] checks
whether the shipping mode in the mv_shipmode variable is
still valid. [shipping resolve=1] updates this variable if necesssary.
Example:
<select name="mv_shipmode">
[shipping free="Free!" label=1
format=|<option value="%M"%S>%D</option>|
mode=|[shipping possible=1]|
]
</select>
Interchange 5.9.0:
Source: code/SystemTag/shipping.coretag
Lines: 18
# 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: shipping.coretag,v 1.5 2007-03-30 23:40:49 pajamian Exp $ UserTag shipping Order mode UserTag shipping addAttr UserTag shipping attrAlias tables table UserTag shipping attrAlias carts cart UserTag shipping attrAlias modes mode UserTag shipping attrAlias name mode UserTag shipping PosNumber 1 UserTag shipping Version $Revision: 1.5 $ UserTag shipping MapRoutine Vend::Ship::tag_shipping
Source: lib/Vend/Ship.pm
Lines: 1101
sub tag_shipping {
my($mode, $opt) = @_;
$opt = { noformat => 1, convert => 1 } unless $opt;
return resolve_shipmode($mode, $opt)
if $opt->{possible} || $opt->{resolve} || $opt->{check_validity};
$Ship_its = 0;
if(! $mode) {
if($opt->{widget} || $opt->{label}) {
$mode = resolve_shipmode(undef, { no_set => $opt->{no_set}, possible => 1});
}
else {
$mode = $opt->{handling}
? ($::Values->{mv_handling})
: ($::Values->{mv_shipmode} || 'default');
}
}
my $loc = $Vend::Cfg->{Shipping_repository}
&& $Vend::Cfg->{Shipping_repository}{default};
$loc ||= {};
$Vend::Cfg->{Shipping_line} = []
if $opt->{reset_modes};
read_shipping(undef, $opt) if $Vend::Cfg->{SQL_shipping};
read_shipping(undef, $opt) if $opt->{add};
read_shipping($opt->{file}) if $opt->{file};
my $out;
#::logDebug("Shipping mode(s) $mode");
my (@modes) = grep /\S/, split /[\s,\0]+/, $mode;
if($opt->{default}) {
undef $opt->{default}
if tag_shipping($::Values->{mv_shipmode});
}
if($opt->{label} || $opt->{widget}) {
my @out;
if($opt->{widget}) {
$opt->{label} = 1;
$opt->{output_options} = 1;
}
for(@modes) {
my $return = shipping($_, $opt);
#::logDebug("pushing $return");
#push @out, shipping($_, $opt);
push @out, $return;
}
@out = grep /=.+/, @out;
if(! @out and ! $opt->{hide_error}) {
my $message = $loc->{no_modes_message} || 'Not enough information';
@out = "=" . errmsg($message);
}
if($opt->{widget}) {
my $o = { %$opt };
$o->{type} = delete $o->{widget};
$o->{passed} = join ",", @out;
$o->{name} ||= 'mv_shipmode';
$o->{value} ||= $::Values->{mv_shipmode};
$out = Vend::Form::display($o);
}
else {
$out = join "", @out;
}
}
else {
### If the user has assigned to shipping or handling,
### we use their value
if($Vend::Session->{assigned}) {
my $tag = $opt->{handling} ? 'handling' : 'shipping';
$out = $Vend::Session->{assigned}{$tag}
if defined $Vend::Session->{assigned}{$tag}
&& length( $Vend::Session->{assigned}{$tag});
}
### If no assignment has been made, we read the shipmodes
### and use their value
unless (defined $out) {
$out = 0;
for(@modes) {
$out += shipping($_, $opt) || 0;
}
}
$out = Vend::Util::round_to_frac_digits($out);
## Conversion would have been done above, force to 0, as
## found by Frederic Steinfels
$out = currency($out, $opt->{noformat}, 0, $opt);
}
return $out unless $opt->{hide};
return;
}