0

I have built an Ubercart site, using the Node Access Product module, that sells only two products, one of which is access to a single node. Everything works correctly, but after the customer makes a successful purchase the following errors are repeated all the down the completed order page:

"Notice: Trying to get property of non-object in nap_save_purchase() (line 1508 of /home/mysite/public_html/sites/all/modules/nap/nap.module)"

and

"Notice: Undefined index: type in drupal_write_record() (line 7025 of /home/mysite/public_html/includes/common.inc)"

I have been everywhere looking for an answer. Can anyone help?

2 Answers 2

1

This error is thrown when an object is empty, and you attempt to determine the value of a property. In this case the following code is responsible:

 // Go through each of the products purchased.
  for ($i = 0; $i < count($product_nodes); $i++) {
    // Easy referencing.
    $node = &$product_nodes[$i];
    $settings = nap_get_nap_settings($node->nid); <- Throws error

My guess is that $product_nodes is empty.

Try wrapping the for loop as follows:

 // Go through each of the products purchased.
  if (!empty($product_nodes)) {
    for ($i = 0; $i < count($product_nodes); $i++) {
      // Easy referencing.
      $node = &$product_nodes[$i];
      $settings = nap_get_nap_settings($node->nid);

      ..rest of loop code ...

    } //End of for loop
  }

This should work. You should also bring this up as an issue on the project page.

1
  • @Patrick Wire - This was already an issue on D.O.. I know you are new to Drupal Answers, but if the answer helped, please indicate it by accepting the answer so other will know it has been solved. Otherwise please post a comment indicating that it did not work so we can look for other solutions.
    – Triskelion
    Commented Mar 28, 2013 at 23:41
0

2 things.

  • Somewhere in your code your saving something with a column type in a database table. It's probably in nap_save_purchase(). The field is blank when you save the record to the DB. fix that.
  • You have all error messages likely going to the screen on your live website. You can hide Notice messages in your settings.php file with like ini_set('error_reporting', 'E_ALL ^ E_NOTICE');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.