Magento: Bypass Checkout for Free Products The 2019 Stack Overflow Developer Survey Results Are InWhy only HTTP links are supported as source for downloadable products?How to hide/disable the checkbox of a free(price = 0) downloadable product?How can I add a “Downloadable Product” to a Bundle?Magento bypass Payment MethodLooking for a real One-Click Checkout for downloadable productsCode to enable downloadable product?Changing limit on number of downloads for past and future purchases - Downloadable ProductsAllow “shipping address” for downloadable productsUnable to checkout with a downloadable productMagento 1.9.3.7 Set expiration time/date for downloadable products

What are the motivations for publishing new editions of an existing textbook, beyond new discoveries in a field?

How come people say “Would of”?

"What time...?" or "At what time...?" - what is more grammatically correct?

Extreme, unacceptable situation and I can't attend work tomorrow morning

If a poisoned arrow's piercing damage is reduced to 0, do you still get poisoned?

Pristine Bit Checking

JSON.serialize: is it possible to suppress null values of a map?

Deadlock Graph and Interpretation, solution to avoid

Lethal sonic weapons

Confusion about non-derivable continuous functions

What does Linus Torvalds means when he says that git "never ever" tracks a file?

What is a mixture ratio of propellant?

Where to refill my bottle in India?

What is this 4-propeller plane?

Why could you hear an Amstrad CPC working?

"Riffle" two strings

What does "rabbited" mean/imply in this sentence?

Inversion Puzzle

Is three citations per paragraph excessive for undergraduate research paper?

Is "plugging out" electronic devices an American expression?

I looked up a future colleague on LinkedIn before I started a job. I told my colleague about it and he seemed surprised. Should I apologize?

Realistic Alternatives to Dust: What Else Could Feed a Plankton Bloom?

Access elements in std::string where positon of string is greater than its size

Is flight data recorder erased after every flight?



Magento: Bypass Checkout for Free Products



The 2019 Stack Overflow Developer Survey Results Are InWhy only HTTP links are supported as source for downloadable products?How to hide/disable the checkbox of a free(price = 0) downloadable product?How can I add a “Downloadable Product” to a Bundle?Magento bypass Payment MethodLooking for a real One-Click Checkout for downloadable productsCode to enable downloadable product?Changing limit on number of downloads for past and future purchases - Downloadable ProductsAllow “shipping address” for downloadable productsUnable to checkout with a downloadable productMagento 1.9.3.7 Set expiration time/date for downloadable products



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








2















I'm triying to create a new module to bypass checkout process for free downloadable products. As I'm not a developer I need some help with xml files of module.



I've this folder structure:



app/etc/modules/Fe_Freecheckout.xml

app/code/local/Fe/Freecheckout/controllers/CheckoutController.php app/code/local/Fe/Freecheckout/etc/config.xml


And these are the contents of files:



CheckoutController.php



<?php
public function purchaseAction()
if (!Mage::getSingleton('customer/session')->isLoggedIn())
$this->_redirectUrl(Mage::getBaseUrl().'customer/account');
return;

$request = $this->getRequest();
$id = $request->getParam('id');
$product = Mage::getModel('catalog/product')
->load($id)
->setStoreId(Mage::app()->getStore()->getId());
if(!($product->getIsVirtual() && $product->getFinalPrice() == 0))
Mage::getSingleton('checkout/session')->addError($this->__('Method only available for Free Downloadable Items'));
return $this;

$onepage = Mage::getSingleton('checkout/type_onepage');
/* @var $onepage Mage_Checkout_Model_Type_Onepage */
try
$quote = $onepage->getQuote();
/* @var $quote Mage_Sales_Model_Quote */
$quote->addProduct($product);
Mage::getSingleton('checkout/session')->setCartWasUpdated(true);
$onepage->initCheckout();
$payment=array('method'=>'free');
$onepage->savePayment($payment);
$onepage->saveOrder();
$this->getResponse()->setRedirect('/downloadable/customer/products');

catch(Exception $e)
$result = $e->getMessage();
Mage::getSingleton('checkout/session')->addError($result);


?>


app/etc/modules/Fe_Freecheckout.xml



<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<Fe_Freecheckout>

<!-- Whether our module is active: true or false -->
<active>true</active>

<!-- Which code pool to use: core, community or local -->
<codePool>local</codePool>

</Fe_Freecheckout>
</modules>
</config>


And this is app/code/local/Fe/Freecheckout/etc/config.xml:



<?xml version="1.0" encoding="UTF-8"?>

<config>
<modules>
<Fe_Freecheckout>
<version>0.0.1</version>
</Fe_Freecheckout>
</modules>

<global>
<rewrite>
<Fe_Freecheckout_checkout_onepagecontroller>
<from><![CDATA[#^/checkout/onepage/#]]></from> <!-- Mage_Checkout_OnepageController -->
<to>/Freecheckout/checkout_onepage/</to> <!-- Package_ModuleName_Checkout_OnepageController -->
</Fe_Freecheckout_checkout_onepagecontroller>
</rewrite>
</global>
</config>


Then in product/view.phtml I use the following code to checkout:



<?php if($_product->isVirtual() && $_product->getFinalPrice()==0) ?>
<a href="/Freecheckout/checkout/purchase/id/<?php echo $_product->getId()?>"><?php echo $this->__('Download and Install') ?></a>
<?php ?>


I always get a Page not Found. Any directions, please?










share|improve this question
















bumped to the homepage by Community 5 hours ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.





















    2















    I'm triying to create a new module to bypass checkout process for free downloadable products. As I'm not a developer I need some help with xml files of module.



    I've this folder structure:



    app/etc/modules/Fe_Freecheckout.xml

    app/code/local/Fe/Freecheckout/controllers/CheckoutController.php app/code/local/Fe/Freecheckout/etc/config.xml


    And these are the contents of files:



    CheckoutController.php



    <?php
    public function purchaseAction()
    if (!Mage::getSingleton('customer/session')->isLoggedIn())
    $this->_redirectUrl(Mage::getBaseUrl().'customer/account');
    return;

    $request = $this->getRequest();
    $id = $request->getParam('id');
    $product = Mage::getModel('catalog/product')
    ->load($id)
    ->setStoreId(Mage::app()->getStore()->getId());
    if(!($product->getIsVirtual() && $product->getFinalPrice() == 0))
    Mage::getSingleton('checkout/session')->addError($this->__('Method only available for Free Downloadable Items'));
    return $this;

    $onepage = Mage::getSingleton('checkout/type_onepage');
    /* @var $onepage Mage_Checkout_Model_Type_Onepage */
    try
    $quote = $onepage->getQuote();
    /* @var $quote Mage_Sales_Model_Quote */
    $quote->addProduct($product);
    Mage::getSingleton('checkout/session')->setCartWasUpdated(true);
    $onepage->initCheckout();
    $payment=array('method'=>'free');
    $onepage->savePayment($payment);
    $onepage->saveOrder();
    $this->getResponse()->setRedirect('/downloadable/customer/products');

    catch(Exception $e)
    $result = $e->getMessage();
    Mage::getSingleton('checkout/session')->addError($result);


    ?>


    app/etc/modules/Fe_Freecheckout.xml



    <?xml version="1.0" encoding="UTF-8"?>
    <config>
    <modules>
    <Fe_Freecheckout>

    <!-- Whether our module is active: true or false -->
    <active>true</active>

    <!-- Which code pool to use: core, community or local -->
    <codePool>local</codePool>

    </Fe_Freecheckout>
    </modules>
    </config>


    And this is app/code/local/Fe/Freecheckout/etc/config.xml:



    <?xml version="1.0" encoding="UTF-8"?>

    <config>
    <modules>
    <Fe_Freecheckout>
    <version>0.0.1</version>
    </Fe_Freecheckout>
    </modules>

    <global>
    <rewrite>
    <Fe_Freecheckout_checkout_onepagecontroller>
    <from><![CDATA[#^/checkout/onepage/#]]></from> <!-- Mage_Checkout_OnepageController -->
    <to>/Freecheckout/checkout_onepage/</to> <!-- Package_ModuleName_Checkout_OnepageController -->
    </Fe_Freecheckout_checkout_onepagecontroller>
    </rewrite>
    </global>
    </config>


    Then in product/view.phtml I use the following code to checkout:



    <?php if($_product->isVirtual() && $_product->getFinalPrice()==0) ?>
    <a href="/Freecheckout/checkout/purchase/id/<?php echo $_product->getId()?>"><?php echo $this->__('Download and Install') ?></a>
    <?php ?>


    I always get a Page not Found. Any directions, please?










    share|improve this question
















    bumped to the homepage by Community 5 hours ago


    This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.

















      2












      2








      2


      2






      I'm triying to create a new module to bypass checkout process for free downloadable products. As I'm not a developer I need some help with xml files of module.



      I've this folder structure:



      app/etc/modules/Fe_Freecheckout.xml

      app/code/local/Fe/Freecheckout/controllers/CheckoutController.php app/code/local/Fe/Freecheckout/etc/config.xml


      And these are the contents of files:



      CheckoutController.php



      <?php
      public function purchaseAction()
      if (!Mage::getSingleton('customer/session')->isLoggedIn())
      $this->_redirectUrl(Mage::getBaseUrl().'customer/account');
      return;

      $request = $this->getRequest();
      $id = $request->getParam('id');
      $product = Mage::getModel('catalog/product')
      ->load($id)
      ->setStoreId(Mage::app()->getStore()->getId());
      if(!($product->getIsVirtual() && $product->getFinalPrice() == 0))
      Mage::getSingleton('checkout/session')->addError($this->__('Method only available for Free Downloadable Items'));
      return $this;

      $onepage = Mage::getSingleton('checkout/type_onepage');
      /* @var $onepage Mage_Checkout_Model_Type_Onepage */
      try
      $quote = $onepage->getQuote();
      /* @var $quote Mage_Sales_Model_Quote */
      $quote->addProduct($product);
      Mage::getSingleton('checkout/session')->setCartWasUpdated(true);
      $onepage->initCheckout();
      $payment=array('method'=>'free');
      $onepage->savePayment($payment);
      $onepage->saveOrder();
      $this->getResponse()->setRedirect('/downloadable/customer/products');

      catch(Exception $e)
      $result = $e->getMessage();
      Mage::getSingleton('checkout/session')->addError($result);


      ?>


      app/etc/modules/Fe_Freecheckout.xml



      <?xml version="1.0" encoding="UTF-8"?>
      <config>
      <modules>
      <Fe_Freecheckout>

      <!-- Whether our module is active: true or false -->
      <active>true</active>

      <!-- Which code pool to use: core, community or local -->
      <codePool>local</codePool>

      </Fe_Freecheckout>
      </modules>
      </config>


      And this is app/code/local/Fe/Freecheckout/etc/config.xml:



      <?xml version="1.0" encoding="UTF-8"?>

      <config>
      <modules>
      <Fe_Freecheckout>
      <version>0.0.1</version>
      </Fe_Freecheckout>
      </modules>

      <global>
      <rewrite>
      <Fe_Freecheckout_checkout_onepagecontroller>
      <from><![CDATA[#^/checkout/onepage/#]]></from> <!-- Mage_Checkout_OnepageController -->
      <to>/Freecheckout/checkout_onepage/</to> <!-- Package_ModuleName_Checkout_OnepageController -->
      </Fe_Freecheckout_checkout_onepagecontroller>
      </rewrite>
      </global>
      </config>


      Then in product/view.phtml I use the following code to checkout:



      <?php if($_product->isVirtual() && $_product->getFinalPrice()==0) ?>
      <a href="/Freecheckout/checkout/purchase/id/<?php echo $_product->getId()?>"><?php echo $this->__('Download and Install') ?></a>
      <?php ?>


      I always get a Page not Found. Any directions, please?










      share|improve this question
















      I'm triying to create a new module to bypass checkout process for free downloadable products. As I'm not a developer I need some help with xml files of module.



      I've this folder structure:



      app/etc/modules/Fe_Freecheckout.xml

      app/code/local/Fe/Freecheckout/controllers/CheckoutController.php app/code/local/Fe/Freecheckout/etc/config.xml


      And these are the contents of files:



      CheckoutController.php



      <?php
      public function purchaseAction()
      if (!Mage::getSingleton('customer/session')->isLoggedIn())
      $this->_redirectUrl(Mage::getBaseUrl().'customer/account');
      return;

      $request = $this->getRequest();
      $id = $request->getParam('id');
      $product = Mage::getModel('catalog/product')
      ->load($id)
      ->setStoreId(Mage::app()->getStore()->getId());
      if(!($product->getIsVirtual() && $product->getFinalPrice() == 0))
      Mage::getSingleton('checkout/session')->addError($this->__('Method only available for Free Downloadable Items'));
      return $this;

      $onepage = Mage::getSingleton('checkout/type_onepage');
      /* @var $onepage Mage_Checkout_Model_Type_Onepage */
      try
      $quote = $onepage->getQuote();
      /* @var $quote Mage_Sales_Model_Quote */
      $quote->addProduct($product);
      Mage::getSingleton('checkout/session')->setCartWasUpdated(true);
      $onepage->initCheckout();
      $payment=array('method'=>'free');
      $onepage->savePayment($payment);
      $onepage->saveOrder();
      $this->getResponse()->setRedirect('/downloadable/customer/products');

      catch(Exception $e)
      $result = $e->getMessage();
      Mage::getSingleton('checkout/session')->addError($result);


      ?>


      app/etc/modules/Fe_Freecheckout.xml



      <?xml version="1.0" encoding="UTF-8"?>
      <config>
      <modules>
      <Fe_Freecheckout>

      <!-- Whether our module is active: true or false -->
      <active>true</active>

      <!-- Which code pool to use: core, community or local -->
      <codePool>local</codePool>

      </Fe_Freecheckout>
      </modules>
      </config>


      And this is app/code/local/Fe/Freecheckout/etc/config.xml:



      <?xml version="1.0" encoding="UTF-8"?>

      <config>
      <modules>
      <Fe_Freecheckout>
      <version>0.0.1</version>
      </Fe_Freecheckout>
      </modules>

      <global>
      <rewrite>
      <Fe_Freecheckout_checkout_onepagecontroller>
      <from><![CDATA[#^/checkout/onepage/#]]></from> <!-- Mage_Checkout_OnepageController -->
      <to>/Freecheckout/checkout_onepage/</to> <!-- Package_ModuleName_Checkout_OnepageController -->
      </Fe_Freecheckout_checkout_onepagecontroller>
      </rewrite>
      </global>
      </config>


      Then in product/view.phtml I use the following code to checkout:



      <?php if($_product->isVirtual() && $_product->getFinalPrice()==0) ?>
      <a href="/Freecheckout/checkout/purchase/id/<?php echo $_product->getId()?>"><?php echo $this->__('Download and Install') ?></a>
      <?php ?>


      I always get a Page not Found. Any directions, please?







      checkout downloadable






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Oct 6 '15 at 22:11









      Adarsh Khatri

      6,78511644




      6,78511644










      asked Oct 6 '15 at 21:19









      Jose LuisJose Luis

      212




      212





      bumped to the homepage by Community 5 hours ago


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







      bumped to the homepage by Community 5 hours ago


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.






















          1 Answer
          1






          active

          oldest

          votes


















          0














          To make a start, can you modify the config.xml file as below:



          <?xml version="1.0" encoding="UTF-8"?>

          <config>
          <modules>
          <Fe_Freecheckout>
          <version>0.0.1</version>
          </Fe_Freecheckout>
          </modules>
          <global>
          <rewrite>
          <fe_freecheckout>
          <from><![CDATA[#^/checkout/onepage/#]]></from> <!-- Mage_Checkout_OnepageController -->
          <to><![CDATA[/freecheckout/checkout/purchase/]]></to> <!-- Package_ModuleName_Checkout_OnepageController -->
          </fe_freecheckout>
          </rewrite>
          </global>
          <frontend>
          <routers>
          <fe_freecheckout>
          <use>standard</use>
          <args>
          <module>Fe_FreeCheckout</module>
          <frontName>freecheckout</frontName>
          </args>
          </fe_freecheckout>
          </routers>
          </frontend>
          </config>


          Are your sure CheckoutController.php looks like how you have posted above? I am not seeing the class Fe_FreeCheckout_CheckoutController declaration. It must look like below:



          <?php
          require_once 'Mage'. DS .'Checkout'. DS .'controllers'. DS .'OnepageController.php';
          class Fe_FreeCheckout_CheckoutController extends Mage_Checkout_OnepageController

          public function purchaseAction()

          if (!Mage::getSingleton('customer/session')->isLoggedIn())

          $this->_redirectUrl(Mage::getBaseUrl().'customer/account');
          return;

          $request = $this->getRequest();
          $id = $request->getParam('id');
          $product = Mage::getModel('catalog/product')
          ->load($id)
          ->setStoreId(Mage::app()->getStore()->getId());
          if(!($product->getIsVirtual() && $product->getFinalPrice() == 0))

          Mage::getSingleton('checkout/session')->addError($this->__('Method only available for Free Downloadable Items'));
          return $this;

          $onepage = Mage::getSingleton('checkout/type_onepage');
          /* @var $onepage Mage_Checkout_Model_Type_Onepage */
          try

          $quote = $onepage->getQuote();
          /* @var $quote Mage_Sales_Model_Quote */
          $quote->addProduct($product);
          Mage::getSingleton('checkout/session')->setCartWasUpdated(true);
          $onepage->initCheckout();
          $payment=array('method'=>'free');
          $onepage->savePayment($payment);
          $onepage->saveOrder();
          $this->getResponse()->setRedirect('/downloadable/customer/products');
          catch(Exception $e)
          $result = $e->getMessage();
          Mage::getSingleton('checkout/session')->addError($result);





          Step 1:
          After these modifications, try to run the URL: http://yourdomain/localhost/freecheckout/checkout/purchase.



          Step 2:
          After trying the URL directly, (if it works), run the URL:
          http://yourdomain/localhost/checkout/onepage, to check if its redirecting to the above mentioned URL.



          Try the above code and steps and let me know if it works for you.



          Happy Coding....






          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%2f85532%2fmagento-bypass-checkout-for-free-products%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









            0














            To make a start, can you modify the config.xml file as below:



            <?xml version="1.0" encoding="UTF-8"?>

            <config>
            <modules>
            <Fe_Freecheckout>
            <version>0.0.1</version>
            </Fe_Freecheckout>
            </modules>
            <global>
            <rewrite>
            <fe_freecheckout>
            <from><![CDATA[#^/checkout/onepage/#]]></from> <!-- Mage_Checkout_OnepageController -->
            <to><![CDATA[/freecheckout/checkout/purchase/]]></to> <!-- Package_ModuleName_Checkout_OnepageController -->
            </fe_freecheckout>
            </rewrite>
            </global>
            <frontend>
            <routers>
            <fe_freecheckout>
            <use>standard</use>
            <args>
            <module>Fe_FreeCheckout</module>
            <frontName>freecheckout</frontName>
            </args>
            </fe_freecheckout>
            </routers>
            </frontend>
            </config>


            Are your sure CheckoutController.php looks like how you have posted above? I am not seeing the class Fe_FreeCheckout_CheckoutController declaration. It must look like below:



            <?php
            require_once 'Mage'. DS .'Checkout'. DS .'controllers'. DS .'OnepageController.php';
            class Fe_FreeCheckout_CheckoutController extends Mage_Checkout_OnepageController

            public function purchaseAction()

            if (!Mage::getSingleton('customer/session')->isLoggedIn())

            $this->_redirectUrl(Mage::getBaseUrl().'customer/account');
            return;

            $request = $this->getRequest();
            $id = $request->getParam('id');
            $product = Mage::getModel('catalog/product')
            ->load($id)
            ->setStoreId(Mage::app()->getStore()->getId());
            if(!($product->getIsVirtual() && $product->getFinalPrice() == 0))

            Mage::getSingleton('checkout/session')->addError($this->__('Method only available for Free Downloadable Items'));
            return $this;

            $onepage = Mage::getSingleton('checkout/type_onepage');
            /* @var $onepage Mage_Checkout_Model_Type_Onepage */
            try

            $quote = $onepage->getQuote();
            /* @var $quote Mage_Sales_Model_Quote */
            $quote->addProduct($product);
            Mage::getSingleton('checkout/session')->setCartWasUpdated(true);
            $onepage->initCheckout();
            $payment=array('method'=>'free');
            $onepage->savePayment($payment);
            $onepage->saveOrder();
            $this->getResponse()->setRedirect('/downloadable/customer/products');
            catch(Exception $e)
            $result = $e->getMessage();
            Mage::getSingleton('checkout/session')->addError($result);





            Step 1:
            After these modifications, try to run the URL: http://yourdomain/localhost/freecheckout/checkout/purchase.



            Step 2:
            After trying the URL directly, (if it works), run the URL:
            http://yourdomain/localhost/checkout/onepage, to check if its redirecting to the above mentioned URL.



            Try the above code and steps and let me know if it works for you.



            Happy Coding....






            share|improve this answer





























              0














              To make a start, can you modify the config.xml file as below:



              <?xml version="1.0" encoding="UTF-8"?>

              <config>
              <modules>
              <Fe_Freecheckout>
              <version>0.0.1</version>
              </Fe_Freecheckout>
              </modules>
              <global>
              <rewrite>
              <fe_freecheckout>
              <from><![CDATA[#^/checkout/onepage/#]]></from> <!-- Mage_Checkout_OnepageController -->
              <to><![CDATA[/freecheckout/checkout/purchase/]]></to> <!-- Package_ModuleName_Checkout_OnepageController -->
              </fe_freecheckout>
              </rewrite>
              </global>
              <frontend>
              <routers>
              <fe_freecheckout>
              <use>standard</use>
              <args>
              <module>Fe_FreeCheckout</module>
              <frontName>freecheckout</frontName>
              </args>
              </fe_freecheckout>
              </routers>
              </frontend>
              </config>


              Are your sure CheckoutController.php looks like how you have posted above? I am not seeing the class Fe_FreeCheckout_CheckoutController declaration. It must look like below:



              <?php
              require_once 'Mage'. DS .'Checkout'. DS .'controllers'. DS .'OnepageController.php';
              class Fe_FreeCheckout_CheckoutController extends Mage_Checkout_OnepageController

              public function purchaseAction()

              if (!Mage::getSingleton('customer/session')->isLoggedIn())

              $this->_redirectUrl(Mage::getBaseUrl().'customer/account');
              return;

              $request = $this->getRequest();
              $id = $request->getParam('id');
              $product = Mage::getModel('catalog/product')
              ->load($id)
              ->setStoreId(Mage::app()->getStore()->getId());
              if(!($product->getIsVirtual() && $product->getFinalPrice() == 0))

              Mage::getSingleton('checkout/session')->addError($this->__('Method only available for Free Downloadable Items'));
              return $this;

              $onepage = Mage::getSingleton('checkout/type_onepage');
              /* @var $onepage Mage_Checkout_Model_Type_Onepage */
              try

              $quote = $onepage->getQuote();
              /* @var $quote Mage_Sales_Model_Quote */
              $quote->addProduct($product);
              Mage::getSingleton('checkout/session')->setCartWasUpdated(true);
              $onepage->initCheckout();
              $payment=array('method'=>'free');
              $onepage->savePayment($payment);
              $onepage->saveOrder();
              $this->getResponse()->setRedirect('/downloadable/customer/products');
              catch(Exception $e)
              $result = $e->getMessage();
              Mage::getSingleton('checkout/session')->addError($result);





              Step 1:
              After these modifications, try to run the URL: http://yourdomain/localhost/freecheckout/checkout/purchase.



              Step 2:
              After trying the URL directly, (if it works), run the URL:
              http://yourdomain/localhost/checkout/onepage, to check if its redirecting to the above mentioned URL.



              Try the above code and steps and let me know if it works for you.



              Happy Coding....






              share|improve this answer



























                0












                0








                0







                To make a start, can you modify the config.xml file as below:



                <?xml version="1.0" encoding="UTF-8"?>

                <config>
                <modules>
                <Fe_Freecheckout>
                <version>0.0.1</version>
                </Fe_Freecheckout>
                </modules>
                <global>
                <rewrite>
                <fe_freecheckout>
                <from><![CDATA[#^/checkout/onepage/#]]></from> <!-- Mage_Checkout_OnepageController -->
                <to><![CDATA[/freecheckout/checkout/purchase/]]></to> <!-- Package_ModuleName_Checkout_OnepageController -->
                </fe_freecheckout>
                </rewrite>
                </global>
                <frontend>
                <routers>
                <fe_freecheckout>
                <use>standard</use>
                <args>
                <module>Fe_FreeCheckout</module>
                <frontName>freecheckout</frontName>
                </args>
                </fe_freecheckout>
                </routers>
                </frontend>
                </config>


                Are your sure CheckoutController.php looks like how you have posted above? I am not seeing the class Fe_FreeCheckout_CheckoutController declaration. It must look like below:



                <?php
                require_once 'Mage'. DS .'Checkout'. DS .'controllers'. DS .'OnepageController.php';
                class Fe_FreeCheckout_CheckoutController extends Mage_Checkout_OnepageController

                public function purchaseAction()

                if (!Mage::getSingleton('customer/session')->isLoggedIn())

                $this->_redirectUrl(Mage::getBaseUrl().'customer/account');
                return;

                $request = $this->getRequest();
                $id = $request->getParam('id');
                $product = Mage::getModel('catalog/product')
                ->load($id)
                ->setStoreId(Mage::app()->getStore()->getId());
                if(!($product->getIsVirtual() && $product->getFinalPrice() == 0))

                Mage::getSingleton('checkout/session')->addError($this->__('Method only available for Free Downloadable Items'));
                return $this;

                $onepage = Mage::getSingleton('checkout/type_onepage');
                /* @var $onepage Mage_Checkout_Model_Type_Onepage */
                try

                $quote = $onepage->getQuote();
                /* @var $quote Mage_Sales_Model_Quote */
                $quote->addProduct($product);
                Mage::getSingleton('checkout/session')->setCartWasUpdated(true);
                $onepage->initCheckout();
                $payment=array('method'=>'free');
                $onepage->savePayment($payment);
                $onepage->saveOrder();
                $this->getResponse()->setRedirect('/downloadable/customer/products');
                catch(Exception $e)
                $result = $e->getMessage();
                Mage::getSingleton('checkout/session')->addError($result);





                Step 1:
                After these modifications, try to run the URL: http://yourdomain/localhost/freecheckout/checkout/purchase.



                Step 2:
                After trying the URL directly, (if it works), run the URL:
                http://yourdomain/localhost/checkout/onepage, to check if its redirecting to the above mentioned URL.



                Try the above code and steps and let me know if it works for you.



                Happy Coding....






                share|improve this answer















                To make a start, can you modify the config.xml file as below:



                <?xml version="1.0" encoding="UTF-8"?>

                <config>
                <modules>
                <Fe_Freecheckout>
                <version>0.0.1</version>
                </Fe_Freecheckout>
                </modules>
                <global>
                <rewrite>
                <fe_freecheckout>
                <from><![CDATA[#^/checkout/onepage/#]]></from> <!-- Mage_Checkout_OnepageController -->
                <to><![CDATA[/freecheckout/checkout/purchase/]]></to> <!-- Package_ModuleName_Checkout_OnepageController -->
                </fe_freecheckout>
                </rewrite>
                </global>
                <frontend>
                <routers>
                <fe_freecheckout>
                <use>standard</use>
                <args>
                <module>Fe_FreeCheckout</module>
                <frontName>freecheckout</frontName>
                </args>
                </fe_freecheckout>
                </routers>
                </frontend>
                </config>


                Are your sure CheckoutController.php looks like how you have posted above? I am not seeing the class Fe_FreeCheckout_CheckoutController declaration. It must look like below:



                <?php
                require_once 'Mage'. DS .'Checkout'. DS .'controllers'. DS .'OnepageController.php';
                class Fe_FreeCheckout_CheckoutController extends Mage_Checkout_OnepageController

                public function purchaseAction()

                if (!Mage::getSingleton('customer/session')->isLoggedIn())

                $this->_redirectUrl(Mage::getBaseUrl().'customer/account');
                return;

                $request = $this->getRequest();
                $id = $request->getParam('id');
                $product = Mage::getModel('catalog/product')
                ->load($id)
                ->setStoreId(Mage::app()->getStore()->getId());
                if(!($product->getIsVirtual() && $product->getFinalPrice() == 0))

                Mage::getSingleton('checkout/session')->addError($this->__('Method only available for Free Downloadable Items'));
                return $this;

                $onepage = Mage::getSingleton('checkout/type_onepage');
                /* @var $onepage Mage_Checkout_Model_Type_Onepage */
                try

                $quote = $onepage->getQuote();
                /* @var $quote Mage_Sales_Model_Quote */
                $quote->addProduct($product);
                Mage::getSingleton('checkout/session')->setCartWasUpdated(true);
                $onepage->initCheckout();
                $payment=array('method'=>'free');
                $onepage->savePayment($payment);
                $onepage->saveOrder();
                $this->getResponse()->setRedirect('/downloadable/customer/products');
                catch(Exception $e)
                $result = $e->getMessage();
                Mage::getSingleton('checkout/session')->addError($result);





                Step 1:
                After these modifications, try to run the URL: http://yourdomain/localhost/freecheckout/checkout/purchase.



                Step 2:
                After trying the URL directly, (if it works), run the URL:
                http://yourdomain/localhost/checkout/onepage, to check if its redirecting to the above mentioned URL.



                Try the above code and steps and let me know if it works for you.



                Happy Coding....







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Feb 8 '16 at 6:50

























                answered Feb 8 '16 at 6:40









                ShivaniShivani

                51125




                51125



























                    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%2f85532%2fmagento-bypass-checkout-for-free-products%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

                    Magento 2 duplicate PHPSESSID cookie when using session_start() in custom php scriptMagento 2: User cant logged in into to account page, no error showing!Magento duplicate on subdomainGrabbing storeview from cookie (after using language selector)How do I run php custom script on magento2Magento 2: Include PHP script in headerSession lock after using Cm_RedisSessionscript php to update stockMagento set cookie popupMagento 2 session id cookie - where to find it?How to import Configurable product from csv with custom attributes using php scriptMagento 2 run custom PHP script

                    Can not update quote_id field of “quote_item” table magento 2Magento 2.1 - We can't remove the item. (Shopping Cart doesnt allow us to remove items before becomes empty)Add value for custom quote item attribute using REST apiREST API endpoint v1/carts/cartId/items always returns error messageCorrect way to save entries to databaseHow to remove all associated quote objects of a customer completelyMagento 2 - Save value from custom input field to quote_itemGet quote_item data using quote id and product id filter in Magento 2How to set additional data to quote_item table from controller in Magento 2?What is the purpose of additional_data column in quote_item table in magento2Set Custom Price to Quote item magento2 from controller

                    How to solve knockout JS error in Magento 2 Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?(Magento2) knockout.js:3012 Uncaught ReferenceError: Unable to process bindingUnable to process binding Knockout.js magento 2Cannot read property `scopeLabel` of undefined on Product Detail PageCan't get Customer Data on frontend in Magento 2Magento2 Order Summary - unable to process bindingKO templates are not loading in Magento 2.1 applicationgetting knockout js error magento 2Product grid not load -— Unable to process binding Knockout.js magento 2Product form not loaded in magento2Uncaught ReferenceError: Unable to process binding “if: function()return (isShowLegend()) ” magento 2