Automatically generating billing in Magento

Sometimes the Magento ordering process results in more work than the customer's wishes. Imagine having a customer using Magento's eCommerce store to make purchases online. Now I want to process my orders with my own customers from the physical store.

If you want to make an order, you must bill and process shipping. This will be cumbersome. Here we go around this, so a successful order is automatically billed by the payment, so it's complete and nothing more is needed.

Create a NAMESPACE folder under app / code / community / MCorner

• Create a "MCornerOrdersObserver" module module as this module is called

• app / code / community / MCorner / MCornerOrdersObserver [19659002] Application / code / community / MCorner / MCornerOrdersObserver / etc

• app / code / community / MCorner / MCornerOrdersObserver / Model

• app / code / community / MCorner / MCornerOrdersObserver /

• Creating the config.xml file

• app / code / community / MCorner / MCornerOrdersObserver / etc / config.xml

• Copy and paste the following code into config.xml

** *** * * * * * * * * [**] * * * * * * * * * ****************************** ******* ************* ******

Creating the Main Observation File:

• app / code / community / MCorner / MCornerOrdersObserver / Model / Observer.php

• Copy b and paste the following code into app / code / community / MCorner / MCornerOrdersObserver / Model / Observer.php

************************* ************ ********* **************************

class MCorner_MCornerOrdersObserver_Model_Observer {

public $ order; // order …

function afterSalesOrderSaveCommitAfter (& $ event) {

return $ this -> __ process ($ event);

}

protected function __process ($ event) {

$ this-> order = $ event-> getEvent () -> getOrder ();

if (! $ This-> order-> getId ()) {

// order has not been saved to the database

return $ this;

}

else {

$ this-> createInvoice ();

}

}

protected function createInvoice () {

$ orderState = $ this-> order-> getState ();

if ($ orderState === Mage_Sales_Model_Order :: STATE_NEW) {// Check the new status.

if ($ this-> order-> canInvoice ()) {

$ this-> order-> getPayment () -> setSkipTransactionCreation (false);

$ invoice = $ this-> order-> prepareInvoice ();

$ account-> setRequestedCaptureCase (Mage_Sales_Model_Order_Invoice :: CAPTURE_ONLINE);

$ account-> register ();

-> addObject ($ this-> order)

-> save ()

-> addObject ($ invoice)

-> addObject;

}

else {

// we can not invoice, so the process is normal.

}

?>

************************** ******************** **************************

A activate the observation module, create a modulos:

• app / etc / modules / MCorner_ MCornerOrdersObserver.xml

• Copy and paste the following code

*********** *** ******************************************** ***

******** *********** ************************* *

Make sure that all the files are stored in their place in the tutorial and now go to Magento Administrator and CLEAR ALL CACHE.

Now if you place an order through the Magento store, you will be billed automatically and billing amount will be charged. We will create an account and send an e-mail. This feature is similar to clicking the Invoice button when administering a Magento account.

Source by Harry Balle Singh

Leave a Reply

Your email address will not be published. Required fields are marked *