3

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?

1 Answer 1

4

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;
        }
    }

}
3
  • Use for Magento 2 like above code with some changes for customer group ? Commented Sep 23, 2016 at 5:57
  • @PayalPatel Didn't check in Magento 2, so not sure, how it will work or behave. Commented Sep 23, 2016 at 7:09
  • @PayalPatel For magento2 how to possible to hide free shipping method for specific customer group you have any idea reply me
    – Rv Singh
    Commented Nov 14, 2018 at 12:22

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.