3

How to get order Id in class Mage_Adminhtml_Block_Sales_Order_Create_Shipping_Method_Form ?

I tried out many ways such as, $this->getQuote->getId();, $this->getOrder->getId(); etc etc... But no Use. I am new in magento and extremely new to Its zend based module structure.

Any help will be appreciated.

3
  • 2
    ... maybe: getQuote() Commented Feb 22, 2013 at 11:17
  • getQuote() is implemented. Should return a quote, this has getOrigOrderId() and getReservedOrderId() with it, you can load the order? Did you try var_dump($this->getData())? Commented Feb 22, 2013 at 11:23
  • @FabianBlechschmidt is his code it calls getQuote as a property not as a method Commented Feb 22, 2013 at 11:24

3 Answers 3

4

First, do you want the quote id or the order id?

If you are after the quote id, try: $this->getQuote()->getId() (note that getQuote is a method).

If you are after order id, I am afraid you cannot do this. The order is created when you press the "place order" button so when you see the output of Mage_Adminhtml_Block_Sales_Order_Create_Shipping_Method_Form, no order exists in the system yet. Only the quote is available at this time.

1
  • Yea. It makes sense. I tried out getting Id using get params also. but no luck!
    – Vishnu R
    Commented Feb 22, 2013 at 13:28
3

I think your problem might be a typo in your code. It looks like you are accesing methods as if they where properties.

Change $this->getQuote->getId(); into $this->getQuote()->getId();

This should work as the quote object is being accessed in that same block in line 140 within Mage_Adminhtml_Block_Sales_Order_Create_Shipping_Method_Form::getShippingPrice()

2
  • I returned The quote Id is already returned using echo $this->getQuote()->getId(); ... But It wont return order Id as you said!
    – Vishnu R
    Commented Feb 22, 2013 at 13:27
  • There is no order Id at that point. The order will be created and assigned an Id once you finish the order creation process (basically when you submit the form)
    – barbazul
    Commented Feb 22, 2013 at 15:57
2

You should be able to do the following, assuming that the order id has been reserved on the quote at the time you're accessing this method.

$order_id = $this->getQuote()->getReservedOrderId();
$order = Mage::getModel('sales/order')->load($order_id);
1
  • 1
    you mean Mage::getModel('sales/order') Commented Feb 22, 2013 at 17:07

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.