RESOLVED
Goal:
To set a maximum shipping weight limit beyond which the usps module is disabled.
Problem:
Special situation where USPS regulations limit how much flammable liquid may be shipped in a package. Specifically, USPS limit is 16 ounces. Furthermore, only one container may be shipped in a package.
We sell 4 oz and 32 oz bottles of a flammable liquid. Obviously, 32 ounces cannot be shipped via USPS. In our case we can only use USPS to ship one 4 ounce bottle per package via Parcel Post. We used the weight of one bottle to determine when the customer has ordered more than one bottle.
To limit a USPS shipment to only one 4 oz bottle, we need to weigh the bottle (a bit over 4 ounces when you include the container). In our case it came to 0.26 lbs. Since two bottles would be 0.52 lbs we set the limit in between these two numbers.
Comments:
This solution has very limited application. If you have a variety of products with differing shipping limitations this solution may not be flexible enough to handle all cases. We only had one product that could go USPS and that product was limited to one bottle per package. Everything else we sell on this site must go UPS or FEDEX ground because they exceed the 16 ounce USPS limit and they are all flammable liquids.
Code changes:
/includes/modules/shipping/usps.php:
around line 58 find:
Code:
function usps() {
global $order, $db, $template;
$this->code = 'usps';
change to:
Code:
function usps() {
global $order, $db, $template, $shipping_weight;
$this->code = 'usps';
around line 69 find:
Code:
// disable only when entire cart is free shipping
if (zen_get_shipping_enabled($this->code)) {
$this->enabled = ((MODULE_SHIPPING_USPS_STATUS == 'True') ? true : false);
}
if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_USPS_ZONE > 0) ) {
$check_flag = false;
change to:
Code:
// disable only when entire cart is free shipping or shipping weight exceeds store set limit
if (zen_get_shipping_enabled($this->code)) {
$this->enabled = ((MODULE_SHIPPING_USPS_STATUS == 'True') ? true : false);
}
if ($shipping_weight >0.3){
$this->enabled = false;
}
if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_USPS_ZONE > 0) ) {
$check_flag = false;
If you wish to explain the limitation to your customers during checkout this can be done here:
/includes/languages/english/php; or
/includes/languages/[yourtemplatename]/english.php:
around line 545 find:
Code:
define('CART_SHIPPING_OPTIONS', 'Estimate Shipping Costs');
change to:
Code:
define('CART_SHIPPING_OPTIONS', 'Estimate Shipping Costs - [add your text here]');
Example:
define('CART_SHIPPING_OPTIONS', 'Estimate Shipping Costs <div> <font size="1"> These are flammable liquids. Postal regulations limit shipments to one 4 ounce bottle per package. (AK, HA, PR: Create a separate order for each additional 4 ounce bottle.) Shipments to states other than AK, HA, PR have the option to use UPS Ground service for orders of any quantity. </font><br /><br /></div>');
Ron