Up to [Local Repository] / interchange / lib / Vend
Request diff between arbitrary revisions
Keyword substitution: kv
Default branch: MAIN
* Fix problem with new-style shipping configuration reading a mixed-case option.
Allow the shipping.asc weight to be modified with weight_callout SpecialSub.
This SpecialSub modifies the 'weight' criteria in shipping.asc. It does not
affect other calculations, such as the [weight] usertag. In the following
example, it is used to exclude items that are part of a free shipping
promotion from the calculation of the shipping cost. That is, if two out of
three items qualify for free shipping, then only the weight of the third
item would be used for weight-based shipping methods.
# Override the normal shipping.asc weight calculations to take the free
# shipping promotion into consideration. Uses custom is_free_shipping and
# weight Item Modifiers. Only non-free-shipping items have their weight
# included.
Sub custom_weight <<EOF
sub {
my ($normal_weight) = @_;
my $new_weight = 0;
for my $item (@$Items) {
$new_weight += $item->{weight} * $item->{quantity}
unless $item->{is_free_shipping};
}
return $new_weight;
}
EOF
SpecialSub weight_callout custom_weight
Augment shipping.asc with shipping_callout SpecialSub.
This change allows you to call another function after the normal shipping
has been calculated, but before the result is returned. It's useful for
the type of customization that would require modifying too many shipping
table entries or using entirely custom shipping code, because it allows
you to build on the powerful shipping features interchange already has.
It is backwards-compatible. For example:
# Calculate shipping as normal with shipping.asc, then apply a discount
# for dealers using UPS shipping methods.
Sub custom_shipping <<EOF
sub {
my ($final, $mode, $opt, $o) = @_;
$final *= .90 if $Scratch->{dealer} and $mode =~ /UPS/i;
return $final;
}
EOF
SpecialSub shipping_callout custom_shipping
* Updated copyright headers to 2007 (closes bug #102) * Added GPL and copyright headers to a few files that were missing them.
More shipping code cleanup
The new Ship.pm seems to have a lot of problems. Here is a patch which addresses the following issues: * Fixed problem where only the last shipping policy will get stored if the multi-line format is used in shipping.asc. * Fixed problem where options are not converted and stored properly on all shipping policies. * Moved more code into the new process_new_beginning sub: * By passing a ref to the @shipping array I can now push new records onto the array from inside the sub. * The above means that the old @list array need not be returned since it's only purpose at that point was to push the record onto @shipping, then immediately be overwritten by @new. * That also means that @new can be assigned to @list inside the sub instead of outside it. * Since we no longer need to return @new, this frees up the return value which I have used to return the $first value instead. * Because $first is returned we no longer need to flag that condition by assigning "_newmode" as the shipping mode. * I also removed an entire redundant elsif branch from read_shipping. The regexp that the branch tested for would never cause the branch to be executed because the branch above it tests for a regexp that matches the same lines. I don't think it's a big deal to change the process_new_beginning sub the way I did because the sub itself is only about 5 weeks old, so the likelyhood of someone having implemented code around it is extremely small.
* Fix shipping line processing bug that put an extra mode at beginning of mode array.
* Change [shipping-desc] to allow access to arbitrary keys in the shipping
configuration.
* Adds key parameter so that you can access any member of the initial shipping
hash for a mode. You can see things like zone, aggregate, adder, etc. as
well as any arbitrary keys you set.
* Allows something like:
usps: USPS 1st class
crit [onlyitems]
min 0
max 0
cost e No shipping needed!
at_least 0
adder 0
p_time 1-2 business days
s_time 3-7 business days
foo bar
min 1
max 6
cost 4.00
min 7
max 12
cost 7.00
[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]
* Thanks to Paul Jordan for suggesting and supporting this!
New Free Software Foundation Address in headers of various files
New Free Software Foundation Address in headers of various files
Stop the [shipping] tag from setting mv_shipmode behind your back, even if you have no_set in your [shipping] tag's options, because the options are not carried forward into each possible invocation of resolve_shipping(). Patch from Jeff Boes <jeff@endpoint.com>.
* Autovivification issue: The temporary mv_shipping cart was left
undefined instead of being removed in some cases. In fact, in the
test case that showed the error, the mv_shipping cart was just being
defined as undef and left as-is. The undef "cart" caused problems
in later cart recalculations.
(back-ported from CVS HEAD)
* Autovivification issue: The temporary mv_shipping cart was left
undefined instead of being removed in some cases. In fact, in the
test case that showed the error, the mv_shipping cart was just being
defined as undef and left as-is. The undef "cart" caused problems
in later cart recalculations.
* Add lockout to list of SpecialSub routines allowed.
* If user-configured lockout routine returns true, it replaces the
current routine completely. If it returns false, the normal one
is run as well.
* Move the logging out of Vend::Dispatch to the do_lockout routine, so
that you can avoid the log entry if your user-configured routine handles
the lockout.
* Make the number of seconds for robot reset adjustable from its
current hardcoded 30:
Limit lockout_reset_seconds
Maybe that should be robot_reset_seconds, I don't know.
* Change use of $Vend::Cfg->{Limit}{member} to $::Limit->{member}. As
Limit is used in iterative routines like chain_cost, this should
improve performance.
Accidently nutralized part of Mike's previous commit.
Added UPS support for countries ouside the US. In order to use this functionality one only needs to add the following two lines to a UPS shipping method in shipping.asc. zone_file products/ship/zone_NL_international.txt country_prefix 1 The zone file 'zone_NLinternational.txt' is TAB delimited and should contain entries like: low high ExpressPlus Express ExpressSaver Standard Expedited "Destination: Belgium (BE). 4-digit code" BE:0000 BE:9999 2 2 2 2 - "Destination: France (FR). 5-digit code" FR:2000 FR:2999 3 3 3 4 - FR:3000 FR:7999 3 4 4 5 - FR:8000 FR:8999 3 3 3 4 - FR:9000 FR:9999 3 4 4 5 - FR:1000 FR:1099 3 3 3 4 - The values in the postcode range should be prepended with the country code. Prepend FR: to postcodes for country France. There is no change to the rate tables.
* Make log message manageable with ErrorDestination. * Allow a "quiet" shipmode that won't log missing areas.
* Make log message manageable with ErrorDestination. * Allow a "quiet" shipmode that won't log missing areas.
* Fix thread-safety problem with shipping adder (and potentially other things).
* Fix thread-safety problem with shipping adder (and potentially other things).
- XHTML-compliance: - lowercased/quoted HTML tags (all containers, so no ">" vs. "/>" issues)
* Incorporate "use strict" for this module. * Improve handling of ship_message. * Avoid some warnings.
* Various variable initializations and tests to avoid warnings.
Make $Session->{ship_message} consistently have a ' ' separator between
messages added to it. (Most places already did this correctly.)
It seems it would be nicer to have an array of shipping messages, but
doing that now would introduce lots of compatibility problems.
Also don't check $Session->{shipping_error}, which seems to be a bug, as
that is never used elsewhere and doesn't make sense in this context.
Allow variable and ITL interpolation in the "free" shipping argument.
Since existing installations will have been using either undef/'' or '1',
this won't slow them down, but it does allow more advanced free shipping
logic, such as (in multi-line shipping.asc notation):
free [if session something]1[/if]
Or in older single-line notation:
{ free => '[if session something]1[/if]' }
* Add @@CRIT@@ marker to cost area.
* Give access to the accumulated criteria with @@CRIT@@ in the "adder". It is a macro substitution as in @@TOTAL@@ (which gives access to the otherwise-final calculated shipping cost. This is a bit confusing, as @@TOTAL@@ gives access to the accumulated criteria in the "cost" area. We probably should add @@CRIT@@ there too.
* Add source_kg, source_oz, and source_grams option for internal UPS -- makes match the Ship::Postal module. * Add packaging_weight option to add a fixed (or variable when passed by parameter) packaging weight when appropriate.
Allow comment lines in shipping.asc, with leading # mark.
Add hide_error option to suppress error message when no shipping methods are found.
The great copyright, email address, URL, and version update.
* Allow relocation of all shipping files with: Shipping default directory products/ship * Update MySQL for 3.23/4.x and transactions (Foundation) * Add Vend::Ship::QueryUPS and Vend::Ship::Postal modules with docs. * Fix bug in UPS query caching. * Allow update_order_status to actually send email.
* Break out shipping stuff from Vend::Interpolate. Add stubs so custom code doesn't break. * Add ability to put custom shipping modules in, called with "cost" field of "s Module". * Improve [ups-query ...] to aggregate shipments and cache prior lookups. * Document [ups-query].