Forum
Perch Shop, having trouble advancing beyond the register customer screen...
Following the flow in the running demo, I have a checkout button on the cart page that advances to checkout which looks like this:
<?php include($_SERVER['DOCUMENT_ROOT'].'/perch/runtime.php');?>
<?php
if (!perch_member_logged_in()) {
PerchSystem::redirect('/register');
}
if (perch_shop_cart_has_property('terms_agreed')) {
perch_shop_checkout('manual', [
'return_url' => '/shop/result',
'cancel_url' => '/shop',
]);
}
perch_layout('global.head', array(
'title' => perch_page_title(true),
'section_heading' => 'shop',
));
perch_layout('global.headwer');
?>
<!-- Page Title
============================================= -->
<section id="page-title">
<div class="container clearfix">
<h1>Checkout</h1>
<ol class="breadcrumb">
<li><a href="#">Home</a></li>
<li><a href="#">Shop</a></li>
<li class="active">Checkout</li>
</ol>
</div>
</section><!-- #page-title end -->
<!-- Content
============================================= -->
<section id="content">
<div class="content-wrap">
<div class="container clearfix">
<div class="row clearfix">
<?php
// Show the cart with a non-interactive template
perch_shop_cart([
'template'=>'cart/cart_static.html'
]);
// Show the order addresses
perch_shop_order_addresses();
// Display the form with the T&Cs checkbox
perch_shop_form('checkout/confirm.html');
?>
</div>
</div>
</section><!-- #content end -->
<?php perch_layout('global.footer'); ?>
</div><!-- #wrapper end -->
<!-- Go To Top
============================================= -->
<div id="gotoTop" class="icon-angle-up"></div>
<?php perch_layout('global.footer.scripts'); ?>
</body>
</html>
Without being logged in, it correctly goes to /register:
<?php include($_SERVER['DOCUMENT_ROOT'].'/perch/runtime.php');?>
<?php
if (perch_member_logged_in()) {
PerchSystem::redirect('/checkout');
}
perch_layout('global.head', array(
'title' => perch_page_title(true),
'section_heading' => 'shop',
));
perch_layout('global.header');
?>
<!-- Page Title
============================================= -->
<section id="page-title">
<div class="container clearfix">
<h1>Checkout</h1>
<ol class="breadcrumb">
<li><a href="#">Home</a></li>
<li><a href="#">Shop</a></li>
<li class="active">Checkout</li>
</ol>
</div>
</section><!-- #page-title end -->
<!-- Content
============================================= -->
<section id="content">
<div class="content-wrap">
<div class="container clearfix">
<div class="row clearfix">
<?php
PerchSystem::set_var('shipping_weight', perch_shop_get_shipping_weight());
perch_shop_registration_form();
?>
</div>
</div>
</div>
</section><!-- #content end -->
<?php perch_layout('global.footer'); ?>
</div><!-- #wrapper end -->
<!-- Go To Top
============================================= -->
<div id="gotoTop" class="icon-angle-up"></div>
<?php perch_layout('global.footer.scripts'); ?>
</body>
</html>
which displays the customer create form which contains the same fields and continue button as in the demo...
But upon submitting the form with the billing shipping addresses, the form does not advance to /checkout...
and I'm stuck on that page with just the form's success message...
What is supposed to move the user forward to the next screen?
That's really up to you, what were you expecting to happen based on your code?
So I'm using nest running demo as a guide... and when I enter my billing and shipping address into the /shop/register page on the nest running demo site, it advances me to /shop/checkout...
I'm trying to understand where in the code that is happening as I think I'm using the same code and it does not advance for me on my work site (https://stopherethisistheplace.com/shop). I'm a little weak on my understanding of where members and customers overlap... By looking at the code, I think it's designed to present the create_customer form if the visitor is not a member... Then when the form is filled, the member/customer is created, the code at the top of register:
would get re-assessed and push onto the checkout page...
I think I’m wrong? If so, I don't know what causes the progression to /checkout from register...
Thanks for your help, I'm a copy-paster learner...
-- Monty
No, that's right. Once a customer registers or logs in, then that code would redirect them.
Shoot. So do you have any thoughts as to what could be wrong?
You would need to debug as normal, find out at which point the code isn't doing what you expect.If you echo something out to the page at various points in the code you can see where it is getting to, also Perch Debug will give you information as to which queries are being run and what Perch is doing internally.
ok, thanks. So it is that statement above that is getting reassessed when the form is submitted that would advance the page to /checkout, right?
I do see that the member record is being created and the new users status is active...
that statement is a PHP redirect. It will redirect to wherever you want it to. You then need to make sure that page is there, correct and won't bounce them somewhere else.
In addition to Rachel's comments have a look at the logs on your server, I've lost count of the times I've stared at blank/ wrong screens wondering what went wrong only to finally open the logs and see "PHP Error........." with some reasonably understandable message.
Are you sure that the redirect is being hit? Try changing
to
Which of those messages do you see in your page? It may at least give you the route being taken through the code
Thank you Kim and Rachel, ok, so adding that, the first time it shows
Before logged in check
then when the form is submitted,
Before logged in checkAfter logged in check
So I tried to load /checkout manually and it forwarded me back to /register!
I guess because of this in register.php:
So I'm not getting logged in when I complete the customer_create form?
If that's correct, am I missing something that would log in the customer wnen they fill out customer_create?
Thank you!
It's worth noting that if you echo anything before the redirect, the redirect won't happen.
However, on the following page you should be logged in and not bounced back.
Do you have any evidence that member login is working for you?
Yes, members app is creating a record from the customer_create form...
and I am able to use the members app to log in, etc...
Is there anything explicit I need to do to log the customer in that I'm missing?
There shouldn't be, no.
Have you turned on debug? What does it output at the point of creating the customer?
Ah...
On register.php I get:
Tried to track down that weird missing template but I can't figure out where that's coming from...
/home/stophere/stopherethisistheplace.com/perchlogin/login_form.html
Is that trying to refer to:
/perch/templates/members/login/login_form.html
I was missing:
from my customer_create.html.
Ouch.