0

I have a product that weighs 30 lbs. However, when a customer orders multiples of this product--say, 10 of them--the total weight should be 300 lbs.

I have an extension for FedEx Freight that is configured for an activation weight of 141 lbs. The regular ground FedEx maximum weight is set to 140 lbs.

Considering these settings, only the freight option should be shown, but at checkout both methods are being given as options for shipping.

What do I need to configure to make sure total weight is taken into consideration, and only one shipping method is shown? I'm a newbie at this, so please be specific if possible.

My Magento version is 1.7.0.2

3 Answers 3

1

You have to write a custom shipping method. To do so, create a custom module and extend the class Mage_Shipping_Model_Carrier_Abstract and use collectRates method:

<?php
class My_CustomShipping_Model_Shipping_Carrier_ShippingMethod extends Mage_Shipping_Model_Carrier_Abstract {

    /**
    * unique internal shipping method identifier
    *
    * @var string [a-z0-9_]
    */
    protected $_code = 'customshipping';


    const MAX_WEIGHT = 141;

    public function collectRates(Mage_Shipping_Model_Rate_Request $request) {
       // skip if not enabled
       if( !Mage::getStoreConfig( 'carriers/' . $this->_code . '/active' ) ) {
          return false;
       }

       $items = $this->_getItems($request);
       $weight = 0.0;
       foreach($items as $item) {
          $product = Mage::getModel('catalog/product')->load($item->getProductId());
          $weight += $item->getQty() * $product->getWeight();
       }

       // Restrict allowed weight
       if($weight > self::MAX_WEIGHT) {
          return false;
       }

       $flatRate = Mage::getStoreConfig('carriers/'.$this->_code.'/flat_rate');
       $result   = Mage::getModel('shipping/rate_result');
       $method   = Mage::getModel('shipping/rate_result_method');

       $method->setCarrier($this->_code);
       $method->setMethod($this->_code);
       $method->setMethodTitle('Weight Limited Shipping');
       $method->setCost($flatRate);
       $method->setPrice($flatRate);

       $result->append($method);

       return $result;
    }
}

Also it would be great to put the MAX_WEIGHT as configuration value.

0

As an another option, if you need to work with FedEX, update FedEx module, then Go to the Configuration -> Shipping Medthods -> FedEx and set Maximum Package Weight to 141 (or any value you need)

2
  • That's how it's currently configured, but it's offering both freight and ground options for an order of 10, when it should only be going freight. Somehow it's taking the weight of only one item into consideration, because different single items over the 140 lb threshold only offer the freight option?
    – user16185
    Commented Nov 11, 2014 at 14:30
  • @user16185 then you have to override the FedEx shipping module (or edit directly the original, which is bad idea) and change the method which is called collectRates. Just make the logic you want there and it should solve the issue. Commented Nov 11, 2014 at 15:54
0

If you have some budget, an excellent (and simple) option would be to install and use the Shipping Override extension from WebShopApps: http://www.webshopapps.com/us/shipping/shipping-override-matrix.html

WebShopApps is a very reputable vendor and their extensions are the go to solution for shipping. I don't work for them, just use their stuff all the time.

With that extension you could pretty easily create a set of rules in a CSV sheet to enable/disable various methods on your site based on weight. See WebShopApps CSV documentation here: http://support.webshopapps.com/override/shipping-rule-setup/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.