Thursday, May 2, 2013

Friday, August 6, 2010

Virtuemart USPS issue

Hi,

Working long nights, once I stuck into USPS implementation in virtuemart. The error was related to xml object creation. I studied the usps file kept under adminstrator/components/com_virtuemart/classes/shipping/usps.php.
The error was something like :-

Fatal error: Call to a member function getText() on a non-object

While in a loop the increment variable $i was used with the function item like:- item($i).
I just changed $i to 0 manually then it picked the o element for shipping rate but it was not picking $i inside it., due to which the object was not being created for the function called in the very next line getText().
SO what I did was, I just applied if condition before getText() function is used to check wether the object exists or not. Just check out the code below.

if($ship_service[$i]){
$ship_service[$i] = $ship_service[$i]->getText();
}

You just have to search getText() in usps.php and just place the object name like $ship_service[$i] in the if condition.

Visit my profile:-

http://www.facebook.com/er.rahul.arora
http://www.indyarocks.com/profile/profile_vview_main.php?uid=88892
http://www.indyarocks.com/blogs/blog_visiterview_main.php?ouid=ODg4OTI=
http://osum.sun.com/profile/RahulArora
http://rahularora87.blogspot.com/
http://www.google.com/profiles/rahularora1987
http://space2all.co.cc/ (Free web hosting)