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 where i don't know how register my checkout controller:
<?xml version="1.0" encoding="UTF-8"?> <!-- The root node for Magento module configuration --> <config> <!-- The module's node contains basic information about each Magento module --> <modules> <!-- This must exactly match the namespace and module's folder names, with directory separators replaced by underscores --> <Fe_Freecheckout> <!-- The version of our module, starting at 0.0.1 --> <version>0.0.1</version> </Fe_Freecheckout> </modules> </config>
What is the required code in config to register the CheckoutController.php?
Thank you.
Hi @restoss
For your requirements you need to do something else, not the one you mentioned. Please follow the links, they will help
Let me know if you stuck at anything.