Forum

Thread tagged as: Question

Perch Shop Checkout Localhost vs. Hosting

I've got an issue where my checkout experience works as it should on localhost but not when I upload files to my hosting provider.

I have implemented a no password, no payment flow with customer_create_passwordless.html and the manual payment gateway.

I use customer_create_passwordless.html form to register the user and have added next="/shop-checkout" to the form to take the user to my checkout page on submission.

The checkout page only contains the perch_shop_checkout() function:


<?php if (perch_member_logged_in()) { // your 'success' return URL $return_url = '/order-complete'; $cancel_url = '/basket'; perch_shop_checkout('manual', [ 'return_url' => $return_url, 'cancel_url' => $cancel_url, ]); } else { echo '<h1>Not logged in</h1>'; } ?>

On localhost it works as it should, completes the order and redirects to the return url. However after I ftp files to hosted server, when I checkout I always get 'Not logged in' on shop-checkout.php as it does not appear to login the user after submitting the customer_create_passwordless.html form.

Is there anything obvious I need to do between testing locally and on external server?

Hamish Irving

Hamish Irving 1 points

  • 4 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

What's different between the servers?

I'd have to ask my hosts. Is there some info that I can provide them which might help diagnose the problem. i.e. how is the user logged in, is it php sessions? Obviously they will be unfamiliar with Perch therefore it would be helpful to explain in the most basic terms what I am trying to achieve and how it might be supported on their server

Rachel Andrew

Rachel Andrew 394 points
Perch Support

Yes you will need sessions enabled.

Has this server passed the compatibility test?

Yes compatibility test passed on this sever, so maybe not to do with sessions?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Are the dev and live servers on the same platform?

I would assume so but I can contact support to make sure. I'm developing locally on MAMP and the host is basic shared hosting with www.lcn.com.

I contacted them yesterday and they confirmed that sessions are enabled by default and since then when I checkout a Customer is created but the Order is not created?

Can test by checking out from here (after adding a Fabric swatch to basket): https://test-chase-erwin-com.php5.hostingweb.co.uk/basket

My shop-checkout.php page is this:

<?php
    if (perch_member_logged_in()) {
        // your 'success' return URL
        $return_url = '/order-complete';
        $cancel_url = '/basket';

        perch_shop_checkout('manual', [
            'return_url' => $return_url,
            'cancel_url' => $cancel_url,
        ]);
        echo '<h1>Logged in</h1>';
    } else {
        echo '<h1>Not logged in</h1>';
    }
?>

But for some reason perch_shop_checkout() is not being called? This still works as it should when testing locally, but not on the hosted server.

Drew McLellan

Drew McLellan 2638 points
Perch Support

So you're saying that a basic test of perch_member_logged_in() is failing on this server?

perch_member_logged_in() is now working and the Customer is created, but no Order is created so it appears perch_shop_checkout() is failing on this server.

After adding debug to the checkout page I can see there is an error with the Address and Shipping missing? Since I am using customer_create_passwordless.html to create the Customer and then initiate the Checkout by using next="/shop-checkout" on that create customer form, is there something I need to do to associate the address added to that form, with the Order address? Again, this all works locally, but is maybe causing the issue on the server?


Debug Message [25] SELECT p.pagePath, pr.routePattern, pr.routeRegExp, p.pageTemplate FROM perch2_pages p LEFT JOIN perch2_page_routes pr ON p.pageID=pr.pageID ORDER BY pr.routeOrder ASC, p.pagePath ASC Matched page: /shop-checkout, so not using routes. Using master page: /templates/pages/shop-checkout.php [1] SELECT * FROM perch2_members_sessions WHERE sessionID='61aec04387a0870744ce534b4b599b4a70fa683b' AND sessionHttpFootprint='ca53acd3059ef774f2bb7d42478846bc577071d9' AND sessionExpires>'2016-10-23 18:11:24' LIMIT 1 User is logged in [1] SELECT * FROM perch2_pages WHERE pagePath='/shop-checkout' LIMIT 1 [1] SELECT * FROM perch2_shop_cart WHERE cartID=313 [1] SELECT * FROM perch2_shop_cart WHERE cartID=313 Checking out with manual Member ID: 18 [1] SELECT * FROM perch2_shop_customers WHERE memberID=18 [1] SELECT billingAddress, shippingAddress FROM perch2_shop_cart WHERE billingAddress IS NOT NULL AND cartID=313 [1] SELECT * FROM perch2_shop_addresses WHERE customerID='14' AND orderID IS NULL AND addressSlug='default' no address INSERT INTO perch2_shop_addresses(addressDynamicFields,addressTitle,addressSlug,addressCreated) VALUES('{\"first_name\":\"Hamish\",\"last_name\":\"Irving\",\"address_1\":false,\"address_2\":false,\"postcode\":false,\"country\":false,\"company\":false,\"city\":false,\"customer\":\"14\",\"phone\":false,\"county\":false,\"instructions\":false}','default','default','2016-10-23 17:11:24') Invalid query: SQLSTATE[HY000]: General error: 1364 Field 'countryID' doesn't have a default value [1] SELECT * FROM perch2_shop_addresses WHERE customerID='14' AND orderID IS NULL AND addressSlug='shipping' no address INSERT INTO perch2_shop_addresses(addressDynamicFields,addressTitle,addressSlug,addressCreated) VALUES('{\"first_name\":\"Hamish\",\"last_name\":\"Irving\",\"address_1\":false,\"address_2\":false,\"postcode\":false,\"country\":false,\"company\":false,\"city\":false,\"customer\":\"14\",\"phone\":false,\"county\":false,\"instructions\":false}','shipping','shipping','2016-10-23 17:11:24') Invalid query: SQLSTATE[HY000]: General error: 1364 Field 'countryID' doesn't have a default value Customer or Address or Shipping missing
Drew McLellan

Drew McLellan 2638 points
Perch Support

Which version of Shop are you running?

Perch Shop 1.0.8

Drew McLellan

Drew McLellan 2638 points
Perch Support

I think we may have addressed the issue you're seeing in Shop 1.0.9, but it'll apply to new setups of the shop.

How do you mean new setups? As in new installs going forward, or I can update and it may fix?

Drew McLellan

Drew McLellan 2638 points
Perch Support

It's to do with how the database tables are created.

Do you have the shop loaded up with a lot of data?

30 pages of products...

Drew McLellan

Drew McLellan 2638 points
Perch Support

How many per page?

Admin page - 24 x 30 around 720 products

Drew McLellan

Drew McLellan 2638 points
Perch Support

Ok, so you'll need to edit the existing tables. I'll see if we can put together some sort of update script.

Ok thanks Drew. So I hold fire on updating?

This is the last remaining item before go-live, do you have any indication of how long it might take so I can manage my clients expectations?

Drew McLellan

Drew McLellan 2638 points
Perch Support

You can update - if I'm able to create an update script for it, it will be as part of the next release.