2

A client of mine sells some products that can not be shipped via regular channels due to extreme size and/or weight.

For these products, I would like to add a setting like "can be shipped regularly". Then, in the checkout process I would like to check if there are any products in the cart having this flag, and if so: only show the shipment option "delivery on appointment".

I have already developed custom shipment carriers/methods, but do not know what would be a good way to disable any shipment methods for carts that contain a product matching the criteria.

I expected that when I set <sort_order>99999</sort_order> in the carrier's config.xml (so it's rendered last) and then having the following code in the Carrier.php model, I would be able to unset any other possible carriers. However, this does not work.

<?php
class Vendor_ExampleCarrier_Model_Carrier
    extends Mage_Shipping_Model_Carrier_Abstract
    implements Mage_Shipping_Model_Carrier_Interface
{
    /** @var string carrier code */
    protected $_code = 'vendor_examplecarrier';

    /**
     * Collect and get rates
     * 
     * @param  Mage_Shipping_Model_Rate_Request $request
     * @return Mage_Shipping_Model_Rate_Result|bool|null
     */
    public function collectRates( Mage_Shipping_Model_Rate_Request $request )
    {
        // ...
        $canShipRegularly = false;
        // ...

        $shippingRateResultModel = Mage::getModel('shipping/rate_result');

        if (true !== $canShipRegularly) {
            // does nothing
            $shippingRatesResultModel->reset();

            // returns empty array
            $shippingRatesResultModel->getAllRates();
        }

        return $shippingRateResultModel;
    }

    // other stuff..
}

I feel this might be a possible solution, if I would be possible to get access to this model in another scope.

Anyone have an idea as to how to accomplish this?

1 Answer 1

1

You should be able to do this with the Magento table rates shipping method. By limiting the weight for the table rate rules they won't show up if an item is added with sufficient weight to invalidate the rule.

You could also make the weight of the over sized products 9999 for example. This way there is a clear difference between shippable products and over sized products.

Then add the appointment method either as different shipping method or separate rule in table rates and you should be good to go

1
  • 1
    Also should be noted there are several extensions to deal with this situation. Most notably Amasty and webshopapps
    – ladle3000
    Commented Feb 14, 2015 at 3:20

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.