wp-e-commerce/WP-e-Commerce — pull request #757 by ReactorShop (2013-12-27 03:09:59+00:00)
Title: PR for issue #756 UPS/USPS modules try to calculate rates over and over

Here are the modifications indicated in issue #756:

a) Modified the TXT_WPSC_OVER_UPS_WEIGHT constant to
TXT_WPSC_OVER_WEIGHT in wpsc-languages/EN_en.php. The text now reads:
"Your order exceeds the standard shipping weight limit. Please contact
us to quote other shipping alternatives.". This text is now used in
both USPS and UPS weight limit checks.

b) Added a checkbox to provide the ability of disabling international
shipping, for those who don't want to offer it. The standard behavior
is not affected (Enabled). This is part of the getQuote initial
conditions check.

c) The UPS module getQuote filter now matches the more efficient USPS
rates initial conditions check. The data checked is the destination
country, zip code, and shipment weight. Then there's a shipper weight
limit check if you want the whole shipment to be rated as one envelope.
If any of these data checks fail, bail. If these datas checks are ok,
check cache and return the rate table if found. Else, continue the rate
table request process.

d) The UPS cache check process now matches the USPS cache check
process, which uses less variables.

e) Moved UPS's shipment being assigned at the constructor to getQuote
(right after the bail checks). This avoids the shipment being assigned
to the ash_ups class every time this class is instantiated during each
session, matching the USPS module behavior.

f) I removed some redundant variable assignments done at the end of
getQuote (rates_expire, set_destination). These values have already
being assigned before the cache check.

g) I'm assigning the shipper's internal name to the $args (UPS) or
$data (USPS) arrays, so the wpsc_cart_shipment hook $this->name
parameter is now changed to $args or $data, depending on the shipper
module. I'm using this hook to apply a partitioning problem/bin packing
algorithm to reduce the package quantity, and therefore reduce the
shipping cost. It's a new hook, so at this point no one else should be
affected with this modification.

h) I'm adding a new hook called wpsc_shipment_data, after setting the
quote request data and before requesting the quote. I'm using this hook
to check if the shipment could be rated as shipped as an envelope
(movies), instead of packages, to modify on the shipment type data flag.

i) I'm adding another hook called wpsc_rates_table right before
returning the rates table. I use this to add packaging costs to the
rates, based on the shipment contents.

If you have any questions or comments, please don't hesitate to ask.