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.

  • 2
    ... maybe: getQuote() – FlorinelChis Feb 22 '13 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())? – Fabian Blechschmidt Feb 22 '13 at 11:23
  • @FabianBlechschmidt is his code it calls getQuote as a property not as a method – FlorinelChis Feb 22 '13 at 11:24
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.

  • Yea. It makes sense. I tried out getting Id using get params also. but no luck! – Vishnu Renku Feb 22 '13 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()

  • I returned The quote Id is already returned using echo $this->getQuote()->getId(); ... But It wont return order Id as you said! – Vishnu Renku 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);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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