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.

Vishnu R
  • 597
  • 1
  • 6
  • 21

3 Answers3

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.

Vishnu R
  • 597
  • 1
  • 6
  • 21
Paul Grigoruta
  • 1,167
  • 7
  • 9
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()

barbazul
  • 289
  • 1
  • 7
  • I returned The quote Id is already returned using echo $this->getQuote()->getId(); ... But It wont return order Id as you said! – Vishnu R Feb 22 '13 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 Feb 22 '13 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);
philwinkle
  • 35,751
  • 5
  • 91
  • 145