I updated from 6.x-2.0-beta4 to 6.x-2.0-beta7 and noticed a strange bug where all nodes handled by uc_node_checkout that were in the shopping cart are deleted when a user successfully checks out. I'm not sure exactly why this was happening but reverting to 6.x-2.0-beta4 fixed the problem. I have attached a screenshot of the settings I use for uc_node_checkout. I'd love to be using the newer version of the module but until I can figure this out I won't be able to. Any help would be appreciated.

Comments

sgerbino’s picture

I can also confirm this behavior, at the moment I just unchecked the option to delete nodes which are removed from cart.

It seems that when you checkout, the item is removed from the cart and therefore deleted.

richygecko’s picture

Am seeing this as well.

uniquename’s picture

StatusFileSize
new1.85 KB

I also found that behavior. For me a way to solve it was to add a new settings variable, that asks if nodes should be deleted on cart checkout. Because I needed them to deleted when removed from cart to prevent orphaned nodes.

Here is a patch, that does that. Because I'm fairly new to creating patches, I hope it is ok...

michellezeedru’s picture

The patch in #3 worked for me. Thanks!

aidanlis’s picture

Assigned: Unassigned » aidanlis
Priority: Normal » Major
bisonbleu’s picture

StatusFileSize
new117.98 KB

Patch in #3 doesn't work for me... :-(

- I've applied the patch to 6.x-2.0-beta7 (after disabling & uninstalling uc_node_checkout). node_checkout nodes are still being deleted upon submitting order.
- I'm currently testing with "Test Gateway 6.x-2.4"

- As stated in #1, unchecking "Delete nodes whose creators remove the associated product from their cart." in the settings tab saves the node_checkout nodes. Not ideal.

aidanlis’s picture

I'm not seeing this behaviour on a fresh install - can anyone give me some steps to reproduce?

bisonbleu’s picture

Version 6.x-2.0-beta8 solved this issue for me. Plus it has new features that simplify the setup process.

aidanlis’s picture

Status: Active » Fixed

Hooray!!

dsbrianwebster’s picture

Status: Fixed » Active

bisonbleu -- I too have upgraded to Version 6.x-2.0-beta8, but this issue persists.

It happens when the following is set in the settings:
[ √] Delete nodes whose creators remove the associated product from their cart.

Reopening issue.

bisonbleu’s picture

Delicious Simplicity is right & I'm wrong. Nodes are still beeing deleted.

I thought all was well... but it was because users didn't have the "delete own" [node type] permission. :-(

I'm launching a new site this coming Sunday... I guess I'm going to revert to beta4. Today is Friday the 13th right?! -- I'll try the patch in #3 again and report back.

When viewing the order I get the following errors (x 3):

  • warning: array_merge() [function.array-merge]: Argument #2 is not an array in /home/bison/public_html/drpl2/profiles/uberdrupal/modules/token/token.module on line 346.
  • warning: array_keys() [function.array-keys]: The first argument should be an array in /home/bison/public_html/drpl2/profiles/uberdrupal/modules/token/token.module on line 349.
  • warning: array_values() [function.array-values]: The argument should be an array in /home/bison/public_html/drpl2/profiles/uberdrupal/modules/token/token.module on line 350.
  • warning: Invalid argument supplied for foreach() in /home/bison/public_html/drpl2/profiles/uberdrupal/modules/token/token.module on line 413.
bisonbleu’s picture

StatusFileSize
new104.51 KB

Ok, after thourough testing, here's what I found (using beta8).

[√] "Behavior settings": Patch in #3 works. I guess when I first patched, I did it wrong. The wording isn't clear to me though.
[√] "Display settings": all work "as advertised".

[x] "Order display settings": there are strange behaviors here (Attribute module is enabled)
- the "node teaser for nodes on orders" is displayed at all times; there's no way to get rid of it!
- checking "Display a node teaser as an attribute/option combination for nodes on orders." generates the errors listed in #11 when viewing the order (see attached screencapture)
- the second option (Add to the default node cart teaser using these settings) depends on "Display the node cart teaser on the cart view form for node checkout products." being checked in the "Display settings" pane.
- this second option seems redundant (?) since the attribute is already displayed underneath the product (unless one can remove that line and use the more customizable option provided by uc_node_checkout).

In short then, beta8 with patch #3 applied seems to behave as it should. That is as far as I can see for my setup.

I'm thinking about reverting to beta4 though. Just to be on the safe side...

SchwebDesign’s picture

It's such a relief to see others experiencing the same thing here. I'm using Beta8 as well and i'll follow bisonbleu's findings and instal patch #3 in hopes that fixes the problem. Thanks for the great work and communication with this module!

aidanlis’s picture

The patch in #3 is fundamentally flawed and does not address the root of the problem - why did this suddenly start happening, and in which version was the regression introduced?

The code in hook_nodeapi('delete') didn't change between beta4 and beta8, so something else is triggering the behaviour.

To progress this issue forward I need someone to work out which version introduced the regression. If it's not in beta4, then if someone could try beta5, beta6, etc until the problem is located. Once that's done, I'll diff the two and see if I can spot any suspects.

SchwebDesign’s picture

thanks for your reply. the patch in #3 "Worked" for you but like you said is not the ideal fix. at the moment i can confirm this issue happened AFTER beta4. i have a new project coming up in the next few weeks that will use this module and i'll install each after beta 5 and try to isolate which version after that introduced the problem. If someone else can do that in the meantime go for it.

also just FYI, patch #3 "gave" me the same order display errors as in #12 above, but now when attempting to view that respective order i get "The page you requested does not exist" 500 error, although it shows as completed on the my order history page.

SchwebDesign’s picture

update: the "The page you requested does not exist" 500 error i got mentioned above after installing the patch from #3 was apparantly a side-effect of the Boost module being installed & enabled and the errors output on (some, not all- not sure why its inconsistent) on the admin order view pages (e.g. http://www.domain.com/admin/store/orders/18) . These errors i got are the exact same as bisonbleu's screenshot. Once i disabled the boost module caching and compression the order view pages worked again with the errors shown.

interestingly, the errors are now gone when viewing the same orders that had them previously. The errors persisted for a while but seem to have disappeared. I wonder if this is some incontestability with the boost module?

Of course, once we patch this the better way as mentioned by aidanlis i'm sure these errors will go away. But documenting it here for good measure.

aidanlis’s picture

As I said, if someone works out where the regression was introduced (beta5, beta6, beta7 or beta8) I will patch it. If noone comes forward I'm going to make this as postponed.

SchwebDesign’s picture

working on it... will get back asap

SchwebDesign’s picture

Alright, here's exactly what I did and found on my new installation and... unfortunately, i cannot replicate this problem!

for the following installations node checkout settings are all default

  1. installed beta 5, linked product to content type, tested with non-admin user account, checkout and node created successfully (not deleted)
    disabled, then uninstalled beta 5, deleted module folder
  2. installed beta 6, linked product to content type, tested with non-admin user account, checkout and node created successfully (not deleted)
    disabled, then uninstalled beta 6, deleted module folder
  3. installed beta 7, linked product to content type, tested with non-admin user account, checkout and node created successfully (not deleted)
    disabled, then uninstalled beta 7, deleted module folder
  4. installed beta 8, linked product to content type, tested with non-admin user account, checkout and node created successfully (not deleted)
    disabled, then uninstalled beta 8, deleted module folder

Here i decided to do it again, but rather than complete uninstall and install I'd do the update.php method, in hopes that would replicate this issue. For good measure, i also checked updating from beta 4.

  1. installed beta 4, linked product to content type, tested with non-admin user account, checkout and node created successfully (not deleted)
    (i assume this was fixed in later betas) went to view content and got error: warning: htmlspecialchars() expects parameter 1 to be string, array given in /home/dir/public_html/includes/bootstrap.inc on line 857.
    did not disable, deleted module folder
  2. uploaded beta 5, ran update.php (no msgs), linked product to content type, tested with non-admin user account, checkout and node created successfully (not deleted)
    went to view content. error above gone for newest node checkout node
    did not disable, deleted module folder
  3. uploaded beta 6, ran update.php (no msgs), linked product to content type, tested with non-admin user account, checkout and node created successfully (not deleted)
    did not disable, deleted module folder
  4. uploaded beta 7, ran update.php (no msgs), linked product to content type, tested with non-admin user account, checkout and node created successfully (not deleted)
    did not disable, deleted module folder
  5. uploaded beta 8, ran update.php (no msgs), linked product to content type, tested with non-admin user account, checkout and node created successfully (not deleted)

Alas, everything worked as expected for all betas with respect to this issue- meaning the nodes were not deleted after successful checkout. ...hmmm so what's next? Perhaps we should each provide a detailed list of other modules we had installed when this happened?

on another note:
I got an error when creating a new classified ad content type that is linked with a UC node checkout product this happened after clicking add to cart on the node checkout new node as test user (not admin)
this is with Upsell, node checkout, and uc recurring installed:
Fatal error: Cannot access empty property in /home/dir/public_html/sites/all/modules/uc_upsell/uc_upsell.module on line 221
I understand this should go into it's own issue, but i found it during the above and want to be thorough in my report. All the above was done AFTER Upsell module was disabled. I doubt it's relevant to this issue.

Hopefully this helps in one way or another!

thank you again for this module, it really is a very well implemented must have for lots of uses.

aidanlis’s picture

Thanks for your investigation Schweb, you've done a great job! Is it possible that you didn't replicate the right circumstances to make the bug occur, e.g. the user you were testing with not having the "delete own" [node type] permission?

SchwebDesign’s picture

No problem. Yes, you're right ... here's what i found:
on the installation where i experienced this issue:

  • create classified_ad content is enabled for test user
  • delete own classified_ad content is enabled for test user
  • delete any classified_ad content is disabled for test user
  • edit own classified_ad content is enabled for test user

on the installation where i couldn't replicate this issue:

  • create classified_ad content is enabled for test user
  • delete own classified_ad content WAS NOT ENABLED for test user
  • delete any classified_ad content is disabled for test user
  • edit own classified_ad content is enabled for test user

I also checked and settings at admin/store/settings/node-checkout/settings were same for both installations

I'll start over again testing the versions with the same permissions enabled.

SchwebDesign’s picture

Alright - looks like it happened between beta4 and beta5. Here's what i found:

made sure permissions were set as:
create classified_ad content is enabled for test user role
delete own classified_ad content is enabled for test user role
delete any classified_ad content is disabled for test user role
edit own classified_ad content is enabled for test user role

installed beta 4, linked product to content type, tested with non-admin user account, checkout and node created successfully (not deleted)
disabled, then uninstalled beta 5, deleted module folder

installed beta 5, linked product to content type, tested with non-admin user account, checkout and node was deleted with message:
"classified ad title has been deleted."
checking order page as admin worked fine but link to node checkout associated node points to path www.domain.com/node/
checking log entries shows "classified_ad: deleted classified ad title."

i hope this helps!!

aidanlis’s picture

Okay, that's awesome work. I will run a diff of those two versions and see if I can work it out.

aidanlis’s picture

aidanlis’s picture

Version: 6.x-2.0-beta7 » 6.x-2.x-dev
Status: Active » Postponed (maintainer needs more info)

Although the above patch in #24 is where the bug was likely introduced, I still can't replicate this bug in -dev. I have all the "delete own x" permissions, and the relevant box ticked on the node checkout settings. After a successful checkout the node is still there...

Please reopen the issue when someone can give me the steps to reproduce this (with -dev) from a blank Drupal install.

aidanlis’s picture

Status: Postponed (maintainer needs more info) » Active

Bah. I better not postpone it because it's obviously a bug, I just can't find it.

SchwebDesign’s picture

Alright, i started completely over again and here's what i did step by step in hopes that it helps you recreate the issue and find it on your end. THanks for your time fixing this.

installed Drupal 6.20 with clean URLS enabled

enabled and set theme to:
Acquia Prosper 6.x-1.1
enabled Fusion Core 6.x-1.1

went to modules, installed modules:
Path 6.20
Search 6.20
Tracker 6.20
Trigger 6.20
Upload 6.20

admin menu 6.x-3.0-alpha4
CCK
Content 6.x-2.9
Content Permissions 6.x-2.9
Fieldgroup 6.x-2.9
FileField 6.x-3.10
ImageField 6.x-3.10
Link 6.x-2.9
Node Reference 6.x-2.9
Number 6.x-2.9
Option Widgets 6.x-2.9
Text 6.x-2.9
User Reference 6.x-2.9

Token 6.x-1.15
ubercsrt core 6.x-2.4
Attribute 6.x-2.4
Catalog 6.x-2.4
Payment 6.x-2.4
Reports 6.x-2.4
Roles 6.x-2.4
Shipping 6.x-2.4
Shipping Quotes 6.x-2.4
Tax Report 6.x-2.4
Taxes 6.x-2.4
Cart Links 6.x-2.4
Product Kit 6.x-2.4
Stock 6.x-2.4

Free Order 6.x-1.0-beta4

Node Checkout 6.x-2.x-dev (downloaded today 5/23/2011)

Views 6.x-2.12
Views Bulk Operations 6.x-1.10
Views exporter 6.x-2.1

Page Title 6.x-2.3
Path redirect 6.x-1.0-rc2
Pathauto 6.x-1.5
Skinr 6.x-1.6
Global Redirect 6.x-1.2

went to http://domain.com/admin/content/types/add
Created node checkout content type: classified_ad - all settings default

went to http://domain.com/node/add/product
created product for classified ad name: "Create a classified ad"
set SKU: "1"- all other settings default
set "Product and its derivatives are shippable." to unchecked

went to http://domain.com/admin/store/settings/node-checkout
clicked edit for Classified Ad
set Product NID to 1
checked "Disable the preview button for this node type for users without edit any classified_ad content permission."
clicked submit

went to set permissions http://domain.com/admin/user/permissions
enabled anon and auth permissions for:
create classified_ad content
delete own classified_ad content
edit own classified_ad content
view catalog
view own orders
access all views
ensured "delete any classified_ad content" was not enabled for both autho and anon
saved permissions

logged out, accessing site as anon
went to "Create classified ad" product: http://domain.com/content/create-classified-ad
clicked on "add to cart", prompted to log in
clicked "create new account"
creating username and email clicking "create new account"
checking email, clicked one time login URL from email (opened in seperate browser btw)
loggin in with new auth user username and password
setting title "Test node" and body "test"
clicked "add to cart"
clicked checkout from cart
entered billing address
chose "free order" as payment method
clicked Review Order
clicked "submit order"
Next page at "http://domain.com/cart/checkout/complete"
says "Classified Ad test node has been deleted."

I hope this helps!

aidanlis’s picture

Assigned: aidanlis » Unassigned

SchwebDesign it'd take me half a day to try and work out which module in that list is causing the error, although I really appreciate the effort you've put in.

I'm not going to be able to work on this ... if anyone wants to take up the baton please feel free.

SchwebDesign’s picture

Yikes, well thanks for the response, but i do understand. If you had any advice for me on how I could try and work out which module is causing the issue. I know i could test by enabling them one at a time, but do you use other methods like the devel module? I'm not too experienced with how i'd use that to rule out this issue however.

Indeed, help from anyone else would be appreciated as well. For example: lobo235 what modules did you have installed whey this happened to you?

again thanks for your work on this module, it's come a long way and has a very impressive set of functionality

aidanlis’s picture

The only proper way to work out what is causing this is starting with a fresh drupal installation and installing only uc_node_checkout ... verify that the problem doesn't happen, then enable another module, verify the problem doesn't happen, etc.

dsbrianwebster’s picture

Okay, so I finally had a second to check this out on my own.

Here are my findings.
It seems that the the problem is that hook_cart_item(), used on line 717 in uc_node_checkout.module, calls op 'remove' at two different times, and for two very different actions:

1) the customer removes an item from their cart
2) the customer completes check out their cart (to empty the cart).

Since node_delete($data['node_checkout_nid']); is called within the hook_cart_item() remove function... that is way the checkout nodes are being deleted on checkout.

A simple hack could be made to uc_node_checkout.nodule to make sure the delete function is being called at the cart only. I have implemented this as I have a project that needs to launch asap. However, I think the real fix should be within hook_cart_item(), perhaps adding another $op case for checkout.

Here is the hack I implemented in case anyone needs it:

Line 728 of uc_node_checkout.module:
if (variable_get('uc_node_checkout_delete_nodes', TRUE)) {

becomes:
if (variable_get('uc_node_checkout_delete_nodes', TRUE) && !arg(1)) {

bisonbleu’s picture

I also realized a couple of days ago that, upon checkout, the content of the cart is and must be emptied since the transaction is in the process of being "completed".

It dawned on me, that maybe (and just maybe) this is where uc_node_checkout can't make the difference between (1) a cart being emptied by a user removing an item and (2) a cart being emptied (and for good reasons) upon completion of a transaction.

I also launched a registration site a couple of days ago where uc_node_checkout plays an important role. For the time being, i have disabled the "Delete nodes whose creators remove the associated product from their cart." option at admin/store/settings/node-checkout/settings.

Hope this helps...

aidanlis’s picture

I've explained the strategy for resolving this issue: Ubercart does not call hook_cart_item('remove') at the end of a transaction. It's some other module that's calling it, we need to find out which one.

dsbrianwebster’s picture

It is the ubercart hook (hook_cart_item) not another module! I installed only ubercart and node checkout and the problem still exists.

Upon successful checkout Ubercart first calls uc_cart_complete_sale(), which in turn calls uc_cart_empty().

uc_cart_empty() fires the cart item hook with $op set to 'remove' for each item -- thus triggering the node_delete in the Node Checkout module. (http://api.ubercart.org/api/function/uc_cart_empty)

So without there a change w/in the ubercart api, Node Checkout would need a way to differentiate when the hook is called in the cart vs. the when the order is completed.

My previous post demonstrates 1 way to do this that works for me. For now.

aidanlis’s picture

Excellent then, I'm happy to go with the solution you provided ...

cknoebel’s picture

Delicious Simplicity's fix in #31 works for me.

SchwebDesign’s picture

yes i unfortunately just haven't yet had the time to do what i mentioned in #29: http://drupal.org/node/1131406#comment-4544030

thanks for the other comments here. Now implementing #31 and will get back to you eventually on if it worked :)

scottbaetz’s picture

FYI - Another who has resolved the problem by #31!

guntherdevisch’s picture

Super thanks for this solution #31

seanenroute’s picture

Solution #31 doesn't work if the user went into the shopping cart as an anonymous user. It creates the account but then deletes the order.

If the user is signed in then the order is completed and the new node is still there.

dsbrianwebster’s picture

StatusFileSize
new50.93 KB

Sean,

I can't test Anonymous checkout on my current project so I started a new install of drupal + ubercart + uc_node_checkout and I can't replicate the issue you're reporting.

I tested the following scenarios:
1. Checkout as Anonymous user WITH my fix in #31, I proceeded through checkout with no problem. A checkout node authored by Anonymous was saved.

2. Checkout as Anonymous user WITHOUT my fix in #31, and it deleted the node as expected.

(See attached screenshot of the results)

Either you did not make the edit correctly or something else is causing the issue. Thoughts?

bsandor’s picture

Subscribe

dsbrianwebster’s picture

Solution #31 works

bsandor’s picture

I did #31 (http://drupal.org/node/1131406#comment-4555358) and now I have this problem:
Node Checkout Order Status does not follow Ubercart Order Staus (http://drupal.org/node/1238396#comment-4819978)

dsbrianwebster’s picture

This is not causing the problem with the order status field. I have posted the cause and a fix on the post referenced in #44 page: http://drupal.org/node/1238396

As for this issue, #31 is still the way to go.

griz’s picture

Version: 6.x-2.x-dev » 6.x-2.0-beta8
StatusFileSize
new753 bytes

Thanks to Delicious Simplicity for this fix.
Here's a patch that applies to 6.x-2.0-beta8.

jasonawant’s picture

Hi,

Do you have any idea what changes I would have to make to the dev version to make this patch work? Adding the !arg(1) didn't fix it.

Thanks, jwant.

jasonawant’s picture

Hi,

I think the patch in #46 applies #31 fix to the wrong line of code in beta8.

I think #46 patch is applied to line 658 in beta8 version, where as the #31 fix is meant for line 728 as stated in #31. Doing so at 658 doesn't work :/

#31 fix works in beta8 and dev.

jwant

kthull’s picture

subscribe

longwave’s picture

Status: Active » Postponed (maintainer needs more info)

Should no longer be an issue in Ubercart 6.x-2.6 and above due to #744956: hook_cart_item() calls op 'remove' during checkout, can someone please confirm this is the case?

jasonawant’s picture

Hi,

I'm using Ubercart 6.x-2.7 and UC Node Checkout 6.x-2.0-beta8 with a new project, and I can confirm that nodes governed by uc node checkout are not deleted on a successful checkout.

jwant

tr’s picture

Status: Postponed (maintainer needs more info) » Closed (fixed)

Closing as "fixed" because of #50 and #51.