Forum
Perch Shop - Registration page not redirecting to checkout on live site
HI,
I have been working on developing a shop installation on a client site (local XAMPP installation) and little by little, it is all coming together and I finally have some form of working site with roughly the feature set I require.
However, uploading all the files and DB to the live server I have come across a few issues. Most of which I have managed to work around but for some reason if I try to purchase an item, I get redirected to the registration page, but then, upon completion of the registration, the page does not redirect back to the checkout page.
Initially, I jumped at the notion that it must be to do with differences in the 'server' set-up, but given my workflow, I do not believe this is the case.
Currently, the user selects a product and is sent to the cart page. From here they select 'checkout' and this happily redirects the non-logged in user to the registration page:
if (!perch_member_logged_in()) {
PerchSystem::redirect('/shop/register');
}
Once the registration form is filled out, submission should redirect the user back to the checkout page using:
if (perch_member_logged_in()) {
PerchSystem::redirect('/shop/checkout');
}
as the user will now be registered and logged in.
On submission, I can see that a new member has been created, but a blank registration page is returned.
No Debug messages are shown, just a plain html page.
If I add:
if (perch_member_logged_in()) {
echo 'IS THIS TRIGGERED';
PerchSystem::redirect('/shop/checkout');
}
I will see the message, meaning that the if statement is being fired.
I suppose the other point is, if it was a server issue, why would one redirect work and the other not.
All very odd.
My diagnostic report is as below:
Perch Runway: 3.0.8, PHP: 5.6.30, MySQL: mysqlnd 5.0.11-dev - 20120503 - $Id: 76b08b24596e12d4553bd41fc93cccd5bac2fe7a $, with PDO
Server OS: Linux, cgi-fcgi
Installed apps: content (3.0.8), assets (3.0.8), categories (3.0.8), perch_blog (5.5.1), perch_events (1.9.5), perch_forms (1.9), perch_shop_orders (1.2.2), perch_shop_products (1.2.2), perch_shop (1.2.2), perch_members (1.6.2), perch_twitter (3.7)
App runtimes: <?php $apps_list = [ 'perch_blog', 'perch_twitter', 'perch_events', 'perch_forms', 'perch_members', 'perch_shop', ];
PERCH_LOGINPATH: /admin
PERCH_PATH: /home/auk/public_html/admin
PERCH_CORE: /home/auk/public_html/admin/core
PERCH_RESFILEPATH: /home/auk/public_html/admin/resources
Image manipulation: GD Imagick
PHP limits: Max upload 12M, Max POST 12M, Memory: 64M, Total max file upload: 12M
F1: 0c66c2e1f82f9e0b7617b2cb8270f2c7
Resource folder writeable: Yes
DOCUMENT_ROOT: /home/auk/public_html
HTTP_HOST: anticoagulationuk.org
REQUEST_URI: /admin/core/settings/diagnostics/
SCRIPT_NAME: /admin/core/settings/diagnostics/index.php
Thanks
If you think about the fundamentals of what you're doing with HTTP here, it should be clear that this will never work. A redirect uses an HTTP
Location
header and a30x
status code. If you echo anything to the page, you're going to start the response body, which will be necessity end the response header section and so any headers you try to set after that point will be invalid.If you're going to redirect, you need to do that before you send any response body to the browser.
Forget the echo part, that was just purely me trying something to see if the if statement was working, but yes, this will never work.
Redirect does not work though irrespective of this.
Any ideas why the solution will redirect from checkout to registration, but not vice-versa.
Have reverted to using the NEST templates and installed these on the live server. Everything is ok (so the redirect issue must be to do with my personalised templates ??), but it fails at the 'Pay Now' stage.
DEBUG throws up this:
Still a little worried why everything will work locally, but not on the server. Doesn't make for a great development environment, but I presume this could be stricter rules on the server ?
What's the difference between your two environments?
Hi Drew,
My XAMPP set-up is:
Live Server:
Let me know what other information might be useful.
I've been playing around a bit.
Removing the line
from checkout.php removes the Array error as mentioned earlier.
So this leads me to think that within confirm.html, either 'cart-property' is not being sent back, or that the 'Pay Now' button is not triggereing.
Comment removed as talking rubbish !
Definately an issue with the confirm.html template, just not sure why.
Ok, let us know when you have more information.
Still testing, but as soon as confirm.html is contained within checkout.php, the previous error appears.
Evidently,
is not being triggered.
Tried changing the name of the property and a few other elements, but the checkout.php still gives the above error and as such does not progress.
My checkout.php template is:
Ok, I've cracked it and here is the solution for anybody else who finds themselves in this postion.
I have no idea WHY this is working, especially as my local version of Runway / Shop app work fine, but rearranging the checkout template has resolved the issue. I guess the DEBUG error was just one of those classic cases of not really telling me anything useful.
After much fiddling and removal / moving and rearranging of the code, this checkout.php file works for me:
Hopefully this will be of use to others.