Forum
Blank page on checkout
OK, so now on the the next problem! The checkout page was all working fine until I rejigged how I dealt with the addresses for the shop, now though I get a 500 error. There is nothing in my error log.
It is all down to the checkout function (basically if I remove this the page renders just fine):
$return_url = 'https://sgs.localhost/shop/result.php?s=order-success';
$cancel_url = 'https://sgs.localhost/shop/result.php?s=order-cancelled';
perch_shop_checkout('paypal-express', [
'return_url' => $return_url,
'cancel_url' => $cancel_url,
]);
The only thing I changed with regards to that since messing with my address collection was to change the urls to result.php instead of re-using checkout.php. What could be causing the error? I have read on the forums that some people got this error when the shipping was not set up, but I have this set up and it shows correctly in the cart. Maybe once entering the address it screws the shipping up? The address is within the shipping zone of the carrier. CountryID for the address is 236 which is United Kingdom (a selected country within the zone).
Could something about my address collection be screwing with the checkout? Or is it somethign completely different?
Sounds like you don't have error logging enabled, or you're looking at the wrong log somehow.
You are totally right. Did think it was odd. The site is a virtual site on my WAMP and the error log accessed through the control panel was not the one for the site!
Anyway, so this is what it says:
[Tue Oct 18 11:14:03.692383 2016] [:error] [pid 11540:tid 1588] [client 127.0.0.1:54323] PHP Fatal error: Call to a member function memberID() on boolean in C:\UniServerZ\www\sgs.localhost\perch\addons\apps\perch_shop\lib\PerchShop_Order.class.php on line 299, referer: https://sgs.localhost/shop/address.php
Are you checking that the member is logged in before sending them to checkout?
Yes, at the top of the checkout.php I have
Perch doesn't redirect, so it does seem to think the user is logged in but just shows a blank page
Are sessions otherwise persisting ok?
What's the URL when you get the error?
https://sgs.localhost/checkout.php
Yes, if I click the back button, I am still logged in and the cart is till full, etc. Not had any problems with that.
If I change the if statement on checkout.php to redirect if I AM logged in it does redirect as it should, so it seems to know I am logged in even though it apparently says it doesn't know the member ID.
So you never get to either of your result pages?
Does the call to checkout come before any HTML is output?
No I never get to result.php.
Yes, the code above just comes after the perch runtime include - no HTML before it.
It was working before I faffed with the addresses and checkout flow but now I get nothing!
Is it the same error generated each time?
Yup :(
I just put
before perch_shop_checkout() and I get 1 which is the correct member ID.
What does Fatal error: Call to a member function memberID() on boolean mean exactly? Obviously not that it can't retrieve the member ID.
It's trying to get the member ID from the customer, but the customer object is
false
.If you output anything before the
perch_shop_checkout()
function call, it will not work.There is nothing being output before it. I just did it as a test to make sure member ID was being passed to the page.
I just don't get why it is returning false. I am going to try and bypass my address pages to see if it works going straight from cart to checkout
Hmm, well that made no difference! This is very frustrating as it was working at one point before I added all the address stuff and the conditionals before perch_shop_checkout! If it won't work bypassing the new address stuff and without the conditionals, I am running out of ideas...
Is there someway we can get more information about what is going wrong and where beyond the error log?
Diagnostics
Oh well, this is interesting: I created a new member and tried it all out and it works fine! Maybe my deleting the customer addresses from the database while faffing with the whole address set up screwed up the member / customer relationship??
Yes, that's very possible.