Welcome to our Magento blog!

Recently I got many requests for the next part of Magento certificate tutorial series. The followers must be very eager and want to be well-prepared for the exam, thus I tried to take time to start the new chapter: Sales and Customer. From Magento 1.4, administrator can create order for customers in the back-end. It helps admin easily manage his store activity when customer doesn’t place order on the website. My tutorial today will guide you how to create order in admin panel step by step and also mention the way to calculate price when an order is created from admin as well as order state and order status.

1. Steps to create order in admin panel

  • To create a new order in admin, you can follow some steps below:
  • Select Sales > Orders menu
  • Click on the Create New Order button, a customer select page will be shown
  • You can select Customer or Create new Customer for the order. A store select page will be shown
  • Select store where order is placed. Then the page to create order will be displayed. In this page, you need to select product, fulfill customer information (email, address…), select payment method and shipping method.
  • After that, click on the Submit Order button to complete creating an order.

2. Calculating price when an order is created from admin

When you select a product to add to order in backend, you need to choose options (if have) for that product. That’s information to post on sever when you click on Add Selected Product(s) to Order button. The product is added to Order as below:

// app\code\core\Mage\Adminhtml\controllers\Sales\Order\CreateController.php
// _processActionData method
/**
* Adding products to quote from special grid
*/
if ($this->getRequest()->has('item') && !$this->getRequest()->getPost('update_items') && !($action == 'save')) {
$items = $this->getRequest()->getPost('item');
$items = $this->_processFiles($items);
$this->_getOrderCreateModel()->addProducts($items);
}

And when the quote of that order is collected, subtotal is collected first and it calculates the product price:

// app\code\core\Mage\Sales\Model\Quote\Address\Total\Subtotal.php
// _initItem method
} else if (!$quoteItem->getParentItem()) {
$finalPrice = $product->getFinalPrice($quoteItem->getQty());
$item->setPrice($finalPrice)
->setBaseOriginalPrice($finalPrice);
$item->calcRowTotal();
$this->_addAmount($item->getRowTotal());
$this->_addBaseAmount($item->getBaseRowTotal());
$address->setTotalQty($address->getTotalQty() + $item->getQty());
}

In the admin panel, you can change the product price when creating order by Custom Price option. When product item calculates the row total, it was get for the product price:

// app\code\core\Mage\Sales\Model\Quote\Item\Abstract.php
public function calcRowTotal()
{
$qty = $this->getTotalQty();
$total = $this->getCalculationPrice()*$qty;
$baseTotal = $this->getBaseCalculationPrice()*$qty;
$this->setRowTotal($this->getStore()->roundPrice($total));
$this->setBaseRowTotal($this->getStore()->roundPrice($baseTotal));
return $this;
}
/**
* Get item price used for quote calculation process.
* This method get custom price (if ut defined) or original product final price
*
* @return float
*/
public function getCalculationPrice()
{
$price = $this->_getData('calculation_price');
if (is_null($price)) {
if ($this->hasOriginalCustomPrice()) {
$price = $this->getOriginalCustomPrice();
} else {
$price = $this->getConvertedPrice();
}
$this->setData('calculation_price', $price);
}
return $price;
}

3. Order state and order status

Order in Magento has both states and status for the process. Each state may have one or several statuses and a status can just have one state. By default, state are invisible in Magento frontend and backend, but status is visible. You can view the Magento order’s statuses and states in the Sales module configuration:

<global>
...
<sales>
...
<order>
<statuses>
<pending translate="label"><label>Pending</label></pending>
...
<fraud translate="label"><label>Suspected Fraud</label></fraud>
<payment_review translate="label"><label>Payment Review</label></payment_review>
</statuses>
<states>
<new translate="label">
<label>New</label>
<statuses>
<pending default="1"/>
</statuses>
<visible_on_front>1</visible_on_front>
</new>
...
<payment_review translate="label">
<label>Payment Review</label>
<statuses>
<payment_review default="1"/>
<fraud/>
</statuses>
<visible_on_front>1</visible_on_front>
</payment_review>
</states>
</order>
</sales>
</global>

And you can add custom status and state to the order by adding configuration following the paths global/sales/order/states and global/sales/order/statuses. It may be useful for your custom order process.
This brings me to the end of my tutorial today. For other helpful Magento knowledge, read in Magento Certification of our Magento blog.

Author

Why Magestore? We believe in building a meaningful & long-term relationship with you.

22 Comments

  1. mini mathur Reply

    Hi,

    Is it possible to have the **Magento Certification: Sections Links** at the left sidebar as they were in the previous theme of this blog. It is difficult to navigate to various sections of this blog in the current theme of this blog.

    Its a good blog. Please keep posting.

    Thanks,
    Mini Mathur

    • Hello,
      Thank you for your comment. We will consider your suggestion to make our blog easier to follow. Thanks!

  2. I passed my Magento Certified Develper Exam today. Thank you so much for the wonderful articles on Magento. I couldn’t have have done it without it. 🙂

  3. Thank you for all your articles about the certification, I am now certified 🙂

  4. Hey,

    Thank you for your articles. Will have my exam tomorrow, let’s see how it goes 🙂

    • Hi Rauno,
      Good luck to you. Looking forward to the good news from you soon 🙂

  5. Hi David,

    First of all thx for good posting for Magento article. I have request to you.

    Can you please share some knowledge of magento enterprise edition?

    Thanks,
    Vinod

    • Hello Vinod,
      Thank you for your comment. Regarding your question, I’ll try to prepare and share my knowledge of Magento EE in the near future.

  6. Magento developer Reply

    Hi david its long time to see your new post i am waiting to read new post please add new post i am planing to give exam in this month as in this month there is some offer given by varien people fro retake exam

    • Hi,
      I am sorry. Recently I am too busy with some projects thus I don’t have enough time to write blog. I’m preparing a new part of topic 9 and will try to make it available soon.
      Thank you so much for your interest!

  7. Hi David,

    Good News..)
    I have passed Magento Developer Plus Exam (M70-201) today. Thank you so much for the wonderful articles on Magento exam.

    Thanks!!
    Vinod

    • Hi Vinod,
      Great! I am very happy to hear that. Congrats, Vinod! 🙂

  8. Hi David, I have just passed Magento certified developer exam. Thanks for your contribution through the wonderful article series

  9. Magento Certified Developer Plus Reply

    Thank you so very much for these tutorials. I just aced the Magento Certified Developer Plus this morning. Kudos!!!!!

  10. For Magento version 1.2.1.1 I was gitetng error that Zend_Validate_Hostname_Com class does not exist when orders were placed and emails were not send neither when orders placed nor when orders invoicedI followed a post online where the solutions was to copy/rename Zend_Validate_Hostname_De to Zend_Validate_Hostname_Com. It worked for me and know emails is being sentI looked in mangeto version 1.4 and there is class Zend_Validate_Hostname_Com and that’s probably why this plugin worked right the way for magento version 1.4

    • Hi Nurul,

      An update is always more advanced than an old version. I think you’d better try the most update one.

      Have a good time!

  11. Hi David!

    Could you help me w/ my magento problem. How do I enable auto product alert when it comes back to stock? i know this feature is built in within magento. I just dont know how to activate it. do I need to setup a cron job for this? Thanks in advance

    • Hi Blake,
      You should go to the system config (with path : System > Configuration > Catalog > Catalog > Product Alerts) and find field “Allow Alert When Product Comes Back in Stock”, enable this config.
      If it still doesn’t work, you need recheck your cron job in your website.

  12. Hello David,
    do you know how i can get order details (product and customer details) when a create a order in admin? Thanks

Write A Comment