Flat Shipping rate for per 3 product in magento?












0















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.










share|improve this question

























  • if 7 item then shipping cost 150???

    – Gopal Patel
    Feb 25 '17 at 12:01











  • yes...exactly what i want...

    – Yudi
    Feb 25 '17 at 12:21











  • magento version ?

    – Gopal Patel
    Feb 25 '17 at 13:02
















0















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.










share|improve this question

























  • if 7 item then shipping cost 150???

    – Gopal Patel
    Feb 25 '17 at 12:01











  • yes...exactly what i want...

    – Yudi
    Feb 25 '17 at 12:21











  • magento version ?

    – Gopal Patel
    Feb 25 '17 at 13:02














0












0








0








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.










share|improve this question
















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.







shipping






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 34 mins ago









Teja Bhagavan Kollepara

2,96341847




2,96341847










asked Feb 25 '17 at 11:08









YudiYudi

337121




337121













  • if 7 item then shipping cost 150???

    – Gopal Patel
    Feb 25 '17 at 12:01











  • yes...exactly what i want...

    – Yudi
    Feb 25 '17 at 12:21











  • magento version ?

    – Gopal Patel
    Feb 25 '17 at 13:02



















  • if 7 item then shipping cost 150???

    – Gopal Patel
    Feb 25 '17 at 12:01











  • yes...exactly what i want...

    – Yudi
    Feb 25 '17 at 12:21











  • magento version ?

    – Gopal Patel
    Feb 25 '17 at 13:02

















if 7 item then shipping cost 150???

– Gopal Patel
Feb 25 '17 at 12:01





if 7 item then shipping cost 150???

– Gopal Patel
Feb 25 '17 at 12:01













yes...exactly what i want...

– Yudi
Feb 25 '17 at 12:21





yes...exactly what i want...

– Yudi
Feb 25 '17 at 12:21













magento version ?

– Gopal Patel
Feb 25 '17 at 13:02





magento version ?

– Gopal Patel
Feb 25 '17 at 13:02










1 Answer
1






active

oldest

votes


















1














Magento 1



Follow this tutorial to create custom shipping method



in config.xml



<default>
<carriers>
<customshipping>
<active>1</active>
<model>customshipping/carrier_customshipping</model>
<name>Custom Shipping</name>
<title>Custom Shipping </title>
<description>50 Shipping cost per 3 item</description>
<sort_order>1</sort_order>
</customshipping>
</carriers>
</default>


create shipping model class



<?php  
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()) {
$count=0;
foreach ($request->getAllItems() as $item) {
$count+=$item->getQty();
}
$count=ceil($count/3);
$method = Mage::getModel('shipping/rate_result_method');
$method->setCarrier($this->_code);
$method->setCarrierTitle($this->getConfigData('title'));
$method->setMethod($this->_code);
$method->setMethodTitle($this->getConfigData('name'));
$method->setPrice($count*50);
$method->setCost($count*50);
$result->append($method);
}
else
{
$error = Mage::getModel('shipping/rate_result_error');
$error->setCarrier($this->_code);
$error->setCarrierTitle($this->getConfigData('name'));
$error->setErrorMessage('Shipping Method is not available');
$result->append($error);
}
return $result;
}

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


Created module for you.






share|improve this answer























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "479"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f161749%2fflat-shipping-rate-for-per-3-product-in-magento%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    Magento 1



    Follow this tutorial to create custom shipping method



    in config.xml



    <default>
    <carriers>
    <customshipping>
    <active>1</active>
    <model>customshipping/carrier_customshipping</model>
    <name>Custom Shipping</name>
    <title>Custom Shipping </title>
    <description>50 Shipping cost per 3 item</description>
    <sort_order>1</sort_order>
    </customshipping>
    </carriers>
    </default>


    create shipping model class



    <?php  
    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()) {
    $count=0;
    foreach ($request->getAllItems() as $item) {
    $count+=$item->getQty();
    }
    $count=ceil($count/3);
    $method = Mage::getModel('shipping/rate_result_method');
    $method->setCarrier($this->_code);
    $method->setCarrierTitle($this->getConfigData('title'));
    $method->setMethod($this->_code);
    $method->setMethodTitle($this->getConfigData('name'));
    $method->setPrice($count*50);
    $method->setCost($count*50);
    $result->append($method);
    }
    else
    {
    $error = Mage::getModel('shipping/rate_result_error');
    $error->setCarrier($this->_code);
    $error->setCarrierTitle($this->getConfigData('name'));
    $error->setErrorMessage('Shipping Method is not available');
    $result->append($error);
    }
    return $result;
    }

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


    Created module for you.






    share|improve this answer




























      1














      Magento 1



      Follow this tutorial to create custom shipping method



      in config.xml



      <default>
      <carriers>
      <customshipping>
      <active>1</active>
      <model>customshipping/carrier_customshipping</model>
      <name>Custom Shipping</name>
      <title>Custom Shipping </title>
      <description>50 Shipping cost per 3 item</description>
      <sort_order>1</sort_order>
      </customshipping>
      </carriers>
      </default>


      create shipping model class



      <?php  
      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()) {
      $count=0;
      foreach ($request->getAllItems() as $item) {
      $count+=$item->getQty();
      }
      $count=ceil($count/3);
      $method = Mage::getModel('shipping/rate_result_method');
      $method->setCarrier($this->_code);
      $method->setCarrierTitle($this->getConfigData('title'));
      $method->setMethod($this->_code);
      $method->setMethodTitle($this->getConfigData('name'));
      $method->setPrice($count*50);
      $method->setCost($count*50);
      $result->append($method);
      }
      else
      {
      $error = Mage::getModel('shipping/rate_result_error');
      $error->setCarrier($this->_code);
      $error->setCarrierTitle($this->getConfigData('name'));
      $error->setErrorMessage('Shipping Method is not available');
      $result->append($error);
      }
      return $result;
      }

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


      Created module for you.






      share|improve this answer


























        1












        1








        1







        Magento 1



        Follow this tutorial to create custom shipping method



        in config.xml



        <default>
        <carriers>
        <customshipping>
        <active>1</active>
        <model>customshipping/carrier_customshipping</model>
        <name>Custom Shipping</name>
        <title>Custom Shipping </title>
        <description>50 Shipping cost per 3 item</description>
        <sort_order>1</sort_order>
        </customshipping>
        </carriers>
        </default>


        create shipping model class



        <?php  
        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()) {
        $count=0;
        foreach ($request->getAllItems() as $item) {
        $count+=$item->getQty();
        }
        $count=ceil($count/3);
        $method = Mage::getModel('shipping/rate_result_method');
        $method->setCarrier($this->_code);
        $method->setCarrierTitle($this->getConfigData('title'));
        $method->setMethod($this->_code);
        $method->setMethodTitle($this->getConfigData('name'));
        $method->setPrice($count*50);
        $method->setCost($count*50);
        $result->append($method);
        }
        else
        {
        $error = Mage::getModel('shipping/rate_result_error');
        $error->setCarrier($this->_code);
        $error->setCarrierTitle($this->getConfigData('name'));
        $error->setErrorMessage('Shipping Method is not available');
        $result->append($error);
        }
        return $result;
        }

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


        Created module for you.






        share|improve this answer













        Magento 1



        Follow this tutorial to create custom shipping method



        in config.xml



        <default>
        <carriers>
        <customshipping>
        <active>1</active>
        <model>customshipping/carrier_customshipping</model>
        <name>Custom Shipping</name>
        <title>Custom Shipping </title>
        <description>50 Shipping cost per 3 item</description>
        <sort_order>1</sort_order>
        </customshipping>
        </carriers>
        </default>


        create shipping model class



        <?php  
        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()) {
        $count=0;
        foreach ($request->getAllItems() as $item) {
        $count+=$item->getQty();
        }
        $count=ceil($count/3);
        $method = Mage::getModel('shipping/rate_result_method');
        $method->setCarrier($this->_code);
        $method->setCarrierTitle($this->getConfigData('title'));
        $method->setMethod($this->_code);
        $method->setMethodTitle($this->getConfigData('name'));
        $method->setPrice($count*50);
        $method->setCost($count*50);
        $result->append($method);
        }
        else
        {
        $error = Mage::getModel('shipping/rate_result_error');
        $error->setCarrier($this->_code);
        $error->setCarrierTitle($this->getConfigData('name'));
        $error->setErrorMessage('Shipping Method is not available');
        $result->append($error);
        }
        return $result;
        }

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


        Created module for you.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Feb 25 '17 at 13:08









        Gopal PatelGopal Patel

        2,9952930




        2,9952930






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Magento Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f161749%2fflat-shipping-rate-for-per-3-product-in-magento%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            What other Star Trek series did the main TNG cast show up in?

            Berlina muro

            Berlina aerponto