Viewed   112 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

 Answers

2

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
 
5

In theory an order can have more than one shipment. But if you make a convention to always have one single shipment per order you can get its increment id like this:

$orderIncrementId = 120000012;
$order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
$shipment = $order->getShipmentsCollection()->getFirstItem();
$shipmentIncrementId = $shipment->getIncrementId();
Monday, September 26, 2022
2

In Magento, you can encrypt the data using:

Mage::getModel('core/encryption')->encrypt($data);

and decrypt using:

Mage::getModel('core/encryption')->decrypt($data);
Friday, October 7, 2022
 
amcnabb
 
5

There are two way to do it

  1. if you want to just override block then copy that file from core to your local folder, please maintain the same folder structure as core.

  2. second way I think this is the bese way to do it by creating an extension you can get more details from here

http://inchoo.net/magento/overriding-magento-blocks-models-helpers-and-controllers/

Let me know if you have any query

Thanks

Wednesday, November 30, 2022
 
meesern
 
1

now i used this query for order increment

UPDATE eav_entity_store
INNER JOIN eav_entity_type ON eav_entity_type.entity_type_id = eav_entity_store.entity_type_id
SET eav_entity_store.increment_last_id='0000000000'
WHERE eav_entity_type.entity_type_code='order' AND eav_entity_store.store_id = '1';
UPDATE eav_entity_store
INNER JOIN eav_entity_type ON eav_entity_type.entity_type_id = eav_entity_store.entity_type_id
SET eav_entity_store.increment_prefix='ORD'
WHERE eav_entity_type.entity_type_code='order' AND eav_entity_store.store_id = '1';
Sunday, November 13, 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 :