Shipping Methods – Display for Special Customer Group Only

customer-groupshippingshipping-methods

I want to display certain shipping methods – like "collection by customer" for special customer groups only.
All I found is the Amasty "Shipping & Payment By Customer Groups" extension. Is there a free way to do that?

Best Answer

You can try below code and if it works for you then you can modify and make it better for fulfilling your requirement.
Code hides free-shipping method for wholesale customer group.
Overwritten class Mage_Shipping_Model_Shipping

class Anshu_ShippingFilter_Model_Shipping extends Mage_Shipping_Model_Shipping {

    public function collectCarrierRates($carrierCode, $request) {
        if (!$this->_checkCarrierAvailability($carrierCode, $request)) {
            return $this;
        }
        return parent::collectCarrierRates($carrierCode, $request);
    }

    protected function _checkCarrierAvailability($carrierCode, $request = null) {
        $isLoggedIn = Mage::getSingleton('customer/session')->isLoggedIn();
        if ($isLoggedIn) {

            $groupId = Mage::getSingleton('customer/session')->getCustomerGroupId();
            if (2 == $groupId && 'freeshipping' == $carrierCode) {
                return false;
            }
            return true;
        }
    }

}
Related Topic