Asked  7 Months ago    Answers:  5   Viewed   30 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();
Wednesday, March 31, 2021
answered 7 Months ago

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, March 31, 2021
answered 7 Months ago

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.

Saturday, May 29, 2021
answered 5 Months ago

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, May 29, 2021
answered 5 Months ago

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.

Sunday, October 3, 2021
answered 3 Weeks ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :