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;
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
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.
add a comment |
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
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.
add a comment |
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
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
checkout downloadable
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.
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
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....
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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....
add a comment |
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....
add a comment |
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....
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....
edited Feb 8 '16 at 6:50
answered Feb 8 '16 at 6:40
ShivaniShivani
51125
51125
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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