I am on 1.36...
that is very strange.....
I dont think posting the whole cod.php file here will help. Looking at the situation, ie the error on that line occurs when I open a COD transaction in customers-> orders, would it be easier if I troubleshoot what is called when I open an order?

When I mean open an order, I mean click on the particular transaction, it will then be highlighted, the arrow on it, then click again to open the details... all the COD transaction does not work...