Hitting an error:

warning: Attempt to assign property of non-object in /home6/stantho5/public_html/fcf/sites/all/modules/ubercart/uc_attribute/uc_attribute.module on line 1172.

This error is being generated when a user views a specific page. This page has 3 manually-inserted "Add to cart" buttons, and the error is only thrown when those buttons are rendered.

Buttons are generated when the client selects a product in a CCK node reference field on the edit page. The template then retrieves this value and prints it to the page using this:

drupal_get_form('uc_product_add_to_cart_form', $data->field_newsbox_pref[0]['nid']) ;

... where $data->field_newsbox_pref[0]['nid'] is the product node reference NID. Removing this drupal_get_form() call eliminates the error messages.

I see that line 1172 of uc_attribude.module is protected against empty $product->attributes variables, so I'm wondering if the drupal_get_form() call is passing something unexpected. Should I be building a $product object first?

Thanks for your feedback :)

Comments

tr’s picture

Status: Active » Fixed

uc_product_add_to_cart_form() takes a product object as an argument, not a nid, so you should be doing a $product = node_load($nid) to get the product object, then passing $product to uc_product_add_to_cart_form().

emcniece’s picture

Awesome. Thanks for the explanation!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.