The sales order create page can be difficult to understand at first, even for experienced programmers. Most of the magic happens in these files below. This page is just a quick reference as it can be easy to forget where the order creator files are located or what JS events are called on certain interactions. We will continue to update this page with more info.
Controller: app/code/core/Mage/Adminhtml/controllers/Sales/Order/CreateController.php – the main controller, also handles ajax requests
JS: js/mage/adminhtml/sales.js – handles most of the JS like clicking products on grid, adding products to items ordered, reloading blocks ajax (in combination with the CreateController.php loadBlockAction() there is also a product configure JS loaded js/mage/adminhtml/product/composite/configure.js
Layout: app/design/adminhtml/default/default/layout/sales.xml the layout file – notice that each block that is loaded via ajax has to have its own individual block definition like <adminhtml_sales_order_create_load_block_shipping_address> and so forth
PHTML Template Files: app/design/adminhtml/default/default/template/sales/order/create notice that the form.phtml and data.phtml are the containers for a lot of child blocks.
Customer & Store Selector
On the admin order creator you are first presented with the customer and then the store selector. How does this happen since if you look at app/design/adminhtml/default/default/layout/sales.xml:506 you’ll see all the blocks are loaded at once?
app/design/adminhtml/default/default/template/sales/order/create/form.phtml the display css checks the from block app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Form.php for some post fields to see if it should display the customer selector, store selector, and actual order create form.
Clicking A Product To Add To Order
js/mage/adminhtml/sales.js:499 productGridRowClick is called, this will check if product is configurable and if so show a popup. If not it checks it.
js/mage/adminhtml/sales.js:488 productGridRowInputChange is called which adds product to this.gridProducts object
Clicking Add Selected Products To Order
js/mage/adminhtml/sales.js:638 productGridAddSelected is called, which gets the gridProducts object ready, and then calls on line 653 productConfigureSubmit. On line 818 is productConfigureSubmit which makes an ajax call to loadBlock action of app/code/core/Mage/Adminhtml/controllers/Sales/Order/CreateController.php:376 the loadBlock action processes the form data, checks which blocks to update on line 394
the blocks must each have a definition in app/design/adminhtml/default/default/layout/sales.xml since we are not reloading the entire page (so the definition from app/design/adminhtml/default/default/layout/sales.xml:506 for adminhtml_sales_order_create_index will not work) this is just a thing with how Magento handles layouts if using ajax and loading a block on a page, it must have its own xml definition for that block.