Doesn't look like the selected attributes are ever being writing into the cart. I have a product for sale with 2 different attributes, each with their own price. I have the following in my cart when going through the related create node form with an attribute selected:

a:4:{s:3:"nid";s:2:"55";s:17:"node_checkout_nid";i:63;s:9:"shippable";s:1:"0";s:6:"module";s:10:"uc_product";}

To double check, I un-related said product from a node type and just added one to my cart with the same attribute selected. That entry resulted in the following:

a:4:{s:10:"attributes";a:1:{i:1;s:1:"1";}s:9:"shippable";s:1:"0";s:4:"type";s:7:"product";s:6:"module";s:10:"uc_product";}

I've looked around to see if I can fix it, but I'm very new to coding drupal mods and I can't figure this one out... maybe attributes are just not supported in this dev release?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

luca_cracco’s picture

I'm not sure but maybe the problem is here:

line 709 of uc_node_checkout.module


    // Pass these values to modules for alteration.
    $extra = module_invoke_all('add_to_cart_data', $values);

i changed:


    // Pass these values to modules for alteration.
    $extra = module_invoke_all('uc_add_to_cart_data', $values);

stewart.adam’s picture

This is correct, it looks like in Ubercart 3 the hook was renamed to hook_uc_add_to_cart_data().

robomalo’s picture

Confirmed. This should be an easy fix for the maintainer.

designmonger’s picture

I have added the changes as above an still not getting it to work, receiving errors as well. Any ideas? Here are the warnings

Notice: Trying to get property of non-object in uc_node_checkout_form_alter() (line 390 of......
Notice: Undefined variable: product in uc_node_checkout_form_alter() (line 390 of......

designmonger’s picture

Actually, the above error isn't correct - here is the error I have been receiving:

Warning: Missing argument 2 for _uc_attribute_alter_form(), called in ....../sites/all/modules/uc_node_checkout/uc_node_checkout.module on line 390 and defined in _uc_attribute_alter_form() (line 1270 of ......./sites/all/modules/ubercart/uc_attribute/uc_attribute.module).
Warning: Missing argument 3 for _uc_attribute_alter_form(), called in ......./sites/all/modules/uc_node_checkout/uc_node_checkout.module on line 390 and defined in _uc_attribute_alter_form() (line 1270 of ....../sites/all/modules/ubercart/uc_attribute/uc_attribute.module).

swati.karande’s picture

FileSize
923 bytes

For me its working fine and for above warnings and notices I have attached patch.

designmonger’s picture

Thanks for the patch, however I am still seeing the warnings and the attributes are not being added to the cart still. What version of Ubercart are you using? I have tried using Ubercart 7.x-3.2 and Ubercart 7.x-3.x-dev with the same result. Any help would be appreciated greatly.

swati.karande’s picture

FileSize
227.68 KB

Hi,

I am using Ubercart 7.x-3.2 and UC Node Checkout 7.x-2.x-dev version.

One reason for attributes are not being added because after creating attributes for specific product you need to select the attributes you want to add. They are not automatically added after creating attributes.
If this is not the reason can you please explain steps you follow to add attributes so I can replicate that issue.
I have attached screenshot.
I hope it will help you!

green_eye55’s picture

Same issue here. I am using Ubercart 7.x-3.2 and UC Node Checkout 7.x-2.x-dev version. The patch #6 doesn't work for me. The warnings are still the same. Changing the attributes display type didn't help. The product itself has no price and needs the attributes to get a value.

Edit: Even a product without any attributes causes this error!

neptunethemes’s picture

Any update on this? The module currently doesn't work with attributes at all as far as I can tell - I'm getting the same warnings about uc_attribute_alter_form and they're not being added to the cart. I wish I could contribute to the solution but my php skills are lacking to say the least.

stadulis66’s picture

Has anybody made any progress on this? - I am still getting the same errors. I am using Node Checkout with UC Attributes and they do not want to play nice. Cheers Michael

Warning: Missing argument 2 for _uc_attribute_alter_form(), called in /home/public_html/sites/all/modules/uc_node_checkout/uc_node_checkout.module on line 390 and defined in _uc_attribute_alter_form() (line 1273 of /home/public_html/sites/all/modules/ubercart/uc_attribute/uc_attribute.module).
Warning: Missing argument 3 for _uc_attribute_alter_form(), called in /home/public_html/sites/all/modules/uc_node_checkout/uc_node_checkout.module on line 390 and defined in _uc_attribute_alter_form() (line 1273 of /home/public_html/sites/all/modules/ubercart/uc_attribute/uc_attribute.module).

www.digitalworkhorse.com/

schmook’s picture

Thanks everyone for your time and effort!

I get these errors simply enabling uc_attribute.module. This looks to be an issue with a change in _uc_attribute_alter_form() from Ubercart 6 to 7 by looking at this: http://drupalcontrib.org/api/drupal/contributions!ubercart!uc_attribute!...

In 6 just needed a product passed _uc_attribute_alter_form($product)

But in 7 it's looking for a form ID and Boolean for AJAX _uc_attribute_alter_form($id, &$product, $use_ajax)

I tried an arbitrary form ID and Boolean, but got the white screen of death. Any idea what _uc_attribute_alter_form() is looking for in regards to a Form ID?

Thanks again!

schmook’s picture

I was able to get the errors to go away by changing line 390:
$attributes = _uc_attribute_alter_form(node_load($product_nid));

to:
$attributes = _uc_attribute_alter_form($form['#form_id'], node_load($product_nid), FALSE);

I don't think it solves the problem completely.

stadulis66’s picture

Hi schmook - I did what you did in #13 above, but am now getting the error

Fatal error: Call to a member function fetch() on a non-object in /home/public_html/sites/all/modules/uc_node_checkout/uc_node_checkout.module on line 1142

Did you make any other changes to the uc_node_checkout_module? Or to the attributes module?

Thanks, Michael

schmook’s picture

@stadulis66 nothing else was changed. All that did was to quell the error message when looking at nodes that have a single product associated with Node Checkout. I'm not 100% sure that $form['#form_id'] is the correct 'form id'!

I am trying to get multiple products to be sold by a single node type and can't seem to get the views portion of Node Checkout to work; so I tried attributes. And got errors there, which led me to poke around.

Do we know what version of Ubercart this module is compatible with?? The .info file just lists:
dependencies[] = uc_cart

IMHO seems like we may be dealing with Ubercart 2 function calls in Ubercart 3? Maybe?

mr.andrey’s picture

subscribing...

stadulis66’s picture

Good Question - Does anyone one know what version of Ubercart Node Checkout is compatible with?

stadulis66’s picture

This page indicates node checkout has been released for Ubercart 3.0 http://www.ubercart.org/docs/user/30484/uc_node_checkout

But is is still a Dev version.

schmook’s picture

I believe the module is looking for Views 2 api? I will post a separate issue.

lexle’s picture

Hi Micheal,

I have fixed this bug for your site. I think the solution for #13 is correct, however the $id param is $product_nid.

And here is my fix:

Change:
//it's for Drupal 6 (i think)

$attributes = _uc_attribute_alter_form(node_load($product_nid));

To:
//it's for Drupal 7

$attributes = _uc_attribute_alter_form($product_nid, node_load($product_nid), FALSE);

However, to add attributes when you check out, i have to make:

Change:

// Pass these values to modules for alteration.
$extra = module_invoke_all('add_to_cart_data', $values);

To:

// Pass these values to modules for alteration.
    $extra = module_invoke_all('uc_add_to_cart_data', $values);

Besides, you have to enable settings on this module for the product (Video Promotion).

Thanks and best regards,
Lex

VanD’s picture

Status: Active » Needs review
FileSize
741 bytes

Removed PHP errors and warnings. PHP throws a strict warning if using suggestions from #13 and #20 which has been resolved as well.

idenev’s picture

@stadulis66 in #14. I have the same error after applying the latest patch.

The way to fix it was to change:

// Load the data from the database.
    $result = db_query('SELECT * FROM {uc_cart_products} WHERE data LIKE :nid', array(':nid' => '%\"node_checkout_nid\";i:' . $nid . ';%'))->fetchField();
	
    // If a matching product was found in the DB for this node...
    if ($item = $result->fetch()) {

to:

// Load the data from the database.
    $result = db_query('SELECT * FROM {uc_cart_products} WHERE data LIKE :nid', array(':nid' => '%\"node_checkout_nid\";i:' . $nid . ';%'));
	
    // If a matching product was found in the DB for this node...
    if ($item = $result->fetch()) {

After that, everything worked just fine.

spyderpie’s picture

subscribing, I can't get this module to work either and was wondering if the patches would be applied soon ...
Peace and thanks,
Julie

GemQueen’s picture

After trying a bunch of different suggestions and fixes, I finally got this module work with attributes. I've attached a patch that combines all of the fixes above into one patch. oops screwed up file upload - see #25

GemQueen’s picture

Issue summary: View changes
FileSize
1.68 KB

After trying a bunch of different suggestions and fixes, I finally got this to work. I've attached a patch that combines several fixes from other threads

bisonbleu’s picture

Status: Needs review » Reviewed & tested by the community

Just ran into this issue (when a node is associated to a product via uc_node_checkout, both product attribute and price are deleted from the cart). @GemQueen's patch fixes this, hooray!