I am interested in passing additional order data from Magento to our shipping solution - ShipStation.

I need to calculate the total discount applied and store it as what I believe would be an order attribute. Once it exists, getting it into ShipStation seems relatively straight forward.

My question then would be: How would I begin to calculate and store the total discount applied to an order?

2 Answers 2


Could you not use the base_discount_amount or discount_amount columns that are default to Magento.

  1. base_discount_amount is the discount stored with the default currency,
  2. discount_amount is the discount stored in the currency that the order was placed in,

Note: these fields are stored as negative values against the sales_flat_order table

  • Yes, that is exactly the field I need. For whatever reason, my 3rd party shipping software is not seeing this field. Does it have to be "included" somehow? Is there another step necessary in order for this information to be accessible through the API?
    – sparecycle
    May 20, 2014 at 15:25
  • @deeperDATA I am not sure about the API but magento will be able to get these whenever it has the order object May 20, 2014 at 15:26

I guess you want to create your own input type:

In /app/code/local/Custom/CustomOrderStatus/etc/config.xml








    $installer = $this;

    $installer->addAttribute("order", "my_custom_input_field", array("type"=>"varchar"));
    $installer->addAttribute("quote", "my_custom_input_field", array("type"=>"varchar"));

In /app/code/local/Custom/CustomOrderStatus/Model/Observer.php

class Custom_CustomOrderStatus_Model_Observer 
    public function saveCustomData($event)
        $quote = $event->getSession()->getQuote();
        $quote->setData('my_custom_input_field', $event->getRequestModel()->getPost('my_custom_input_field'));

        return $this;

In /app/design/adminhtml/default/default/template/sales/order/view/info.phtml

My Custom Input Field In php tags: echo $_order->getMyCustomInputField()

In sales/order/form/account.phtml

echo Mage::getSingleton('adminhtml/session_quote')->getQuote()->getMyCustomInputField()

Use this in your field. For the area where i used core files, you should make your own files, just to make sure that core files are not modified.

  • I followed your way but unfortunately its not reaching to my observer ? any reason why ? Aug 24, 2015 at 6:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.