Login
Register

VirtueMart

WooCommerce

Others

Docs

Support

Blog

About

Forum

IMPORTANT ANNOUNCEMENT: Plugin development ceased, all plugins made available freely (GPL)

With great sadness we have to announce that we are ceasing development of all our VirtueMart, WooCommerce and Joomla plugins. Effective immediately, all our plugins -- even those that were paid downloads -- are made available for free from our homepage (GPL license still applies), but we cannot and will not provide any support anymore.

It has been a great pleasure to be part of the thriving development communities of VirtueMart as well as WooCommerce. However, during the last year it became painstakingly clear that in addition to a full-time job, a young family and several other time-consuming hobbies at professional level (like being a professional singer) the plugin development and the support that it requires is not sustainable and is taking its toll. It has been an honor, but it is now time to say good bye!

×

Notice

The forum is in read only mode.
Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC:

PHP Notice: Trying to get property of non-object 06 Sep 2014 06:45 #1

  • ovdemonz
  • ovdemonz's Avatar Topic Author
Error_log output as below;

PHP Notice: Trying to get property of non-object in

1- /plugins/vmshipment/rules_shipping/rules_shipping_base.php on line 564
2- /plugins/vmshipment/rules_shipping/rules_shipping_base.php on line 565
3- /plugins/vmshipment/rules_shipping/rules_shipping_base.php on line 566


rules_shipping_base.php snapshot
prntscr.com/4k4izz

my site info:
  • Joomla 2.5.24
  • Virtuemart 2.6.10

PHP and DB >> prntscr.com/4kgg3f

Do let me know if you want to run debug for my site. tq

PHP Notice: Trying to get property of non-object 09 Sep 2014 05:54 #2

  • ovdemonz
  • ovdemonz's Avatar Topic Author
any update.

PHP Notice: Trying to get property of non-object 09 Sep 2014 12:36 #3

I have also had other reprts for this issue, but I have been unable to either reproduce the problem or determine conditions when it occurs. See e.g.
open-tools.net/forum/shipping-by-rules-p.../4298-php-error.html
open-tools.net/forum/shipping-by-rules-p...f-non-object-in.html


Do you have any additional information that might help track down conditions for the issues? Are you able to reproduce the problem, or does it seem to happen randomly?

Best regards,
Reinhold

PHP Notice: Trying to get property of non-object 09 Sep 2014 15:27 #4

  • ovdemonz
  • ovdemonz's Avatar Topic Author
it is consistence not random. Once entering the checkout page after successfully login, the PHP Notice appear.

Some testing done by removing all the shipping rules and just load simple shipping rules also triggered the same result.

var_dump output;
if (!empty($country)) {
$data['country'] = $country->country_name;
$data['country2'] = $country->country_2_code;
$data['country3'] = $country->country_3_code;
echo var_dump($country->country_name);
echo "<br />";
echo var_dump($country->country_2_code);
echo "<br />";
echo var_dump($country->country_3_code);
echo "<br />";
echo "***********************";
echo "<br />";
}

Output;
string(8) "Malaysia"
string(2) "MY"
string(3) "MYS"
***********************
string(8) "Malaysia"
string(2) "MY"
string(3) "MYS"
***********************
string(8) "Malaysia"
string(2) "MY"
string(3) "MYS"
***********************
string(8) "Malaysia"
string(2) "MY"
string(3) "MYS"
***********************
NULL
NULL
NULL
***********************
NULL
NULL
NULL
***********************
NULL
NULL
NULL
***********************

Hope that help in furthering the investigation.

PHP Notice: Trying to get property of non-object 09 Sep 2014 16:12 #5

  • ovdemonz
  • ovdemonz's Avatar Topic Author
Maybe the NULL trigger the PHP Notice?

PHP Notice: Trying to get property of non-object 09 Sep 2014 19:21 #6

Great that you can reproduce the problem!
Is the output generated by one page loading? I.e. when you load one single page, is that output printed seven times (four times with proper country and three times with NULL)?
Or does the output come from different page loadings (which country did you select in the last, failed cases, where NULL is printed?)?

BTW, the NULL in the output is only the symptom: if $country is not an object, any call to $country->country_name will return NULL.

I just don't understand why $country would not be an object in some cases. In particular, from the VM code, I understand that it will only be NULL or the country object loaded from the database. The first case is excluded by the empty($country) call, and the second case should work fine...

Anyway, I'll still try to find the problem.

Best regards,
Reinhold

PHP Notice: Trying to get property of non-object 09 Sep 2014 19:37 #7

  • ovdemonz
  • ovdemonz's Avatar Topic Author
Yes.. the output was generated by one page loading.

-four times with proper country and three times with NULL.

PHP Notice: Trying to get property of non-object 09 Sep 2014 19:50 #8

  • ovdemonz
  • ovdemonz's Avatar Topic Author
Ahhh find something interesting here... ;)

Fyi, im using "VP One Page Checkout Plugin" for Virtuemart Checkout page. It use Ajax to load that page.

More detail about the product > demos.virtueplanet.com/

After disabling the plugin..The PHP Notice was gone completely. Seems like interoperability issues here..

Hmmm..how to explain this to VP One Page Checkout Vendor? Can you have a quick look at their demos site a see what can be done/suggest.

Guess all other that have this problem might also use this fancy one page checkout. :P

Appreciate your expert advise here. Thanks

PHP Notice: Trying to get property of non-object 09 Sep 2014 20:04 #9

  • ovdemonz
  • ovdemonz's Avatar Topic Author
Digging VP One Page Checkout Plugin forum and found this >>

prntscr.com/4l8q34


i have implemented the change as follows and the problem solved. However appreciate you can advise whether is it ok.

Change this:
$country = $countriesModel->getData();

to this:
$country = $countriesModel->getData();
if(is_array($countries = $country)) {
foreach($countries as $country) {
if($country->virtuemart_country_id == $address['virtuemart_country_id']) {
break;
}
}
}

PHP Notice: Trying to get property of non-object 11 Sep 2014 02:03 #10

Thanks to your debug output, I was now able to track down the actual cause of the problem: Virtuemart's country data model had a function getCountries, that changed the internal cache but didn't properly set the corresponding ID, so the next call to setId would not work. It seems that the OPC plugin you use called the getCountries function, while all my test systems didn't, so I was unable to reproduce. I submitted the proper fix to the VirtueMart core developers, so hopefully the next VM 2.6.x release will fix this issue for good.

I have also added a much cleaner workaround to the plugin and released a new version 4.2 (the workaround by the VP OPC plugin devs works, but is just fighting the symptoms rather than the cause). The proper fix is to add a second $countriesModel->setId(0); call before the existing one. This way, the cache will always be discarded and the proper country will be loaded from the database.

So, please upgrade the plugin to version 4.2 and you should be fine.

Best regards,
Reinhold

[SOLVED] PHP Notice: Trying to get property of non-object 11 Sep 2014 11:03 #11

  • ovdemonz
  • ovdemonz's Avatar Topic Author
Problem solved.

PHP Notice: Trying to get property of non-object 11 Sep 2014 11:06 #12

  • ovdemonz
  • ovdemonz's Avatar Topic Author
Great! ;)
  • Page:
  • 1