Asked  2 Years ago    Answers:  5   Viewed   108 times

I'm trying to get the Order Increment Id in Magento, on the success.phtml page so that I can use this for affiliate tracking.

I'm using the following code, but it is giving an error on the second line;

$order = Mage::getSingleton('sales/order')->getLastOrderId();
$lastOrderId = $order->getIncrementId();

The error reads:

Fatal error: Call to a member function getIncrementId() on a non-object on line 34: $LastOrderId = $order->getIncrementId();

I was wondering if anyone has any ideas on how to get the Order Increment Id? This is the reference number seen in the admin, usually something like: #1000123



If you're specifically doing this on the checkout success page - in success.phtml - then the code to get the order increment ID is already available in the template, since it is displayed to the customer.

You just need the following:

$orderId = $this->getOrderId();

Note that this won't work on other pages so, for those, you'd need to use:

$orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
Monday, August 15, 2022

In your system configuration, customer accounts are shared by website, so the loadByEmail method needs to be used on a customer model that has a value for website_id, and this website ID must correspond to the website to which the customer is associated.

Or, as your controller seems to be an admin one, Mage::app()->getWebsite()->getId() returns 0, which does not correspond.

So, your solution is either to share customer accounts globally (System > Configuration > Customers > Customer Configuration > Account Sharing Options), as it won't change much things if you only run a single website, either to use a website ID that has to be specified by an user, or at least not retrieved by Mage::app()->getWebsite()->getId().

Wednesday, December 7, 2022

I tried everything and the only thing it works is the virtual machine that provides bitnami.

Seriously, I don't know what has this vm, but goes really fast. I tried creating my VM using a fresh installation of Ubuntu, CentOS, etc. But doesn't work so fine like this VM.

Thursday, October 6, 2022

Found the commit:

All output function were moved to SebastianBergmannExporterExporter.

PHPUnit_Util_Type::export($key)=> $this->exporter->export($key), PHPUnit_Util_Type::shortenedExport($value) => $this->exporter->shortenedExport($value)

The only problem now is to invoke exporter within scope.

Saturday, November 5, 2022

I've just found this out and it is pleasantly easy. You could put the following in an upgrade script...


P.S. I've been receiving requests to make an extension of this but one already exists: Custom Order Number Pro. It's commercial but it has a decent sounding list of features.

Monday, August 29, 2022
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :

Browse Other Code Languages