Where is it generated?
If you look in app/code/core/Mage/Sales/Model/Order.php on line 2052 , you will find the following:
$this->setData('protect_code', substr(md5(uniqid(mt_rand(), true) . ':' . microtime(true)), 5, 6));
Here protect_code generated for order (using a combination of md5, uniqid and random integer.
What is it used for?
If you look at app/code/core/Mage/Sales/Helper/Guest.php and find the loadValidOrder function. You will see that protect_code used in some areas to ensure that the loaded order is correct for the guest cookie value.
It is also used in other areas, such as matching tracking information. You can see several instances of the getProtectCode() method called in submit models to compare order with tracking information. Example function used:
public function getTrackingInfoByTrackId() { $track = Mage::getModel('sales/order_shipment_track')->load($this->getTrackId()); if ($track->getId() && $this->getProtectCode() == $track->getProtectCode()) { $this->_trackingInfo = array(array($track->getNumberDetail())); } return $this->_trackingInfo; }
As you can see with $this->getProtectCode() == $track->getProtectCode() , protect_code tracking should match Shipping protect_code .
Axel
source share