awesomemotive / easy-digital-downloads

Sell digital downloads through WordPress
https://easydigitaldownloads.com
GNU General Public License v2.0
867 stars 472 forks source link

Notice: Undefined index: edd_cart_token #1793

Closed NateWr closed 10 years ago

NateWr commented 10 years ago

I received this notice on a localhost installation when trying to restore a saved cart. I clicked save cart then immediately clicked restore cart. Let me know if I can provide any more useful info.

edd-notice

pippinsplugins commented 10 years ago

Thanks, we'll get it fixed.

evertiro commented 10 years ago

Hey nate! Can you provide a bit more detail? Does this ALWAYS happen on save/restore or only in situations where you quickly save then hit restore? I've never seen it happen, but it sounds a bit like a race condition.

pippinsplugins commented 10 years ago

@ghost1227 Can you replicate?

NateWr commented 10 years ago

I'm able to reliably replicate this when I am not logged in to the website. Also, the link above works fine. The error only occurs when clicking the Restore Previous Cart button next to the Save Cart button in the image below:

edd-restore-cart

When I was logged in as admin I was unable to reproduce this problem. Furthermore, when I was logged in, the Restore Previous Cart button did not appear -- only the link at the top appeared.

Also, I tried waiting a while before restoring to see if it was a race condition, but even waiting a minute or two (on a localhost server) didn't help.

evertiro commented 10 years ago

@pippinsplugins Haven't been able to yet @NateWr What operating system are your testing on?

NateWr commented 10 years ago

Win7 using a local WAMP server. I'm booted into Ubuntu at the moment so can't check the PHP versions and other details of that server, but can come back with it later if you need.

pippinsplugins commented 10 years ago

I cannot replicate this in the release/1.9 branch. @NateWr Could you test with that branch?

NateWr commented 10 years ago

@pippinsplugins Sure, but it may take me a few days before I get the time to do so.

NateWr commented 10 years ago

I got a chance to check this out with the release/1.9 branch today, but the notice is still appearing. You're probably already on to this, but I noticed that the URL to restore the cart doesn't contain the token that is displayed above.

edd-no-restore-token

pippinsplugins commented 10 years ago

The token is missing because you are logged in, so it's not needed for the restore button. We show the token in the URL so that users can copy it to their clipboard for later.

pippinsplugins commented 10 years ago

@NateWr I still haven't replicated this. Could you list the exact steps you're following to make it happen?

NateWr commented 10 years ago

@pippinsplugins Click EDD's buy button so it changes to checkout button > Click checkout button > View checkout page > Click Save Cart > Click Restore Previous Cart

You can see the problem live at themeofthecrop.com. The PHP Notice does not appear (WP_DEBUG is off), but the Restore Previous Cart button still fails, with the message "Error: Cart restoration failed. Invalid token." Note that this is NOT the release/1.9 branch on the live site.

I tried briefly to turn on WP_DEBUG on the live site, but I'm getting Strict Standards notices with the Affiliates Pro plugin, and these are causing can't modify header errors with EDD which makes the site unusable. So I can't reproduce it there.

The only other plugins on the site are Affiliates Pro, EDD/Affiliates Pro and EDD/Stripe. I've deactivated all but the core EDD and still getting the notice.

pippinsplugins commented 10 years ago

Thanks. I will try again to replicate it.

pippinsplugins commented 10 years ago

Ok replicated. It only happens to logged-out users.

pippinsplugins commented 10 years ago

Fixed!

NateWr commented 10 years ago

Just reporting back. Tested the fix on my end and it's working. No "Restore Cart" button appears when not logged in. Thanks!

pippinsplugins commented 10 years ago

Great! On Dec 9, 2013 8:23 PM, "Ghost1227" notifications@github.com wrote:

Hey nate! Can you provide a bit more detail? Does this ALWAYS happen on save/restore or only in situations where you quickly save then hit restore? I've never seen it happen, but it sounds a bit like a race condition.

— Reply to this email directly or view it on GitHubhttps://github.com/easydigitaldownloads/Easy-Digital-Downloads/issues/1793#issuecomment-30194243 .