I am trying to create a shipping rule in magento. In this rule I need some functionality like $50 per 3 products will add as shipping rule. If someone added 4 items to 6 items in cart, then the shipping charges should $100 ($50 for first 3 pair of items and other $50 for remain items).

But i am stuck and didn't found any extension or solution for this.

  • if 7 item then shipping cost 150??? Feb 25, 2017 at 12:01
  • yes...exactly what i want...
    – Yudi
    Feb 25, 2017 at 12:21
  • magento version ? Feb 25, 2017 at 13:02

1 Answer 1


Magento 1

Follow this tutorial to create custom shipping method

in config.xml

                <name>Custom Shipping</name>
                <title>Custom  Shipping </title>
                <description>50 Shipping cost per 3 item</description>

create shipping model class

    class Stackexchange_Customshipping_Model_Carrier_Customshipping     
        extends Mage_Shipping_Model_Carrier_Abstract
        implements Mage_Shipping_Model_Carrier_Interface
        protected $_code = 'customshipping';  

        * Collect rates for this shipping method based on information in $request 
        * @param Mage_Shipping_Model_Rate_Request $data 
        * @return Mage_Shipping_Model_Rate_Result 
        public function collectRates(Mage_Shipping_Model_Rate_Request $request){  
            $result = Mage::getModel('shipping/rate_result');

             if ($request->getAllItems()) {
                foreach ($request->getAllItems() as $item) {
                $method = Mage::getModel('shipping/rate_result_method');  
                $error = Mage::getModel('shipping/rate_result_error');
                $error->setErrorMessage('Shipping Method is not available');
            return $result;

         * Get allowed shipping methods
         * @return array
        public function getAllowedMethods()
            return array($this->_code=>$this->getConfigData('name'));

Created module for you.

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.