Forum

Thread tagged as: Question, Shop

Shop sample pages

Where can I see sample shop pages for the whole cart & checkout process? I downloaded the Nest master files but that is for Perch Runway - I am running standard Perch.

I can see the templates, but not the pages so I can't quite get my head around the whole flow of it all.

Lisa Morena

Lisa Morena 1 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

There aren't any sample pages, as there isn't a fixed flow. The idea is that you can build the flow you want for your own site.

OK, maybe you can help with my issue then:

I am using manual payment gateway as no payment will be takem online. So I have the cart page which has simply:

<?php   
perch_shop_cart();
 ?>  

The cart.tpl form goes to shop/checkout/index.php, which has:

if (!perch_shop_cart_has_property('terms_agreed')) {

                perch_shop_cart([
                    'template'=>'cart/cart_static.html'
                ]);
                echo '<div class="left-col-checkout">';
                perch_shop_order_addresses();
                perch_shop_form('checkout/confirm.html');
                echo '</div>';


             } else {



                          perch_shop_checkout('manual', [
                            'return_url' => '/shop/success/index.php',
                            'cancel_url' => '/shop/success/index.php',
                            'status' => 'processing'
                          ]);


             }

So after I click checkout, the order is placed but I am not redirected to my success page. Instead, it stays on the checkout page and I get blank content after perch_shop_checkout ... in other words, anything above that is shown and nothing below it. If I remove that line, the full page displays correctly, but the order is obviously not placed. It is as if there is an error in the code, but it is working so there can't be!

Am I being really dim somewhere here?

Error log says:

PHP Warning: Cannot modify header information - headers already sent in C:\UniServerZ\www\Vanilla-CMS\perch\core\lib\PerchUtil.class.php on line 194, referer: https://localhost/vanilla-cms/shop/cart/

Rachel Andrew

Rachel Andrew 394 points
Perch Support

You can't have anything, even white space before sending redirect headers. So make sure that you aren't outputting HTML or anything else.

No, there isn't anything :/

Rachel Andrew

Rachel Andrew 394 points
Perch Support

That is why you are getting that error, so there is somewhere. See: https://stackoverflow.com/questions/8028957/how-to-fix-headers-already-sent-error-in-php

This is so frustrating. I get the error specifically when I add this bit:

perch_shop_checkout('manual', [
                            'return_url' => '/shop/success/index.php',
                            'cancel_url' => '/shop/success/index.php',
                            'status' => 'processing',
                          ]);

If I remove it, all works fine. Specifically, if I remove the options, so that I have just:

perch_shop_checkout('manual');

Then all is fine. What the hell is it about the options that it doesn't like?!

Drew McLellan

Drew McLellan 2638 points
Perch Support

perch_shop_checkout() is trying to redirect to your success page, but it can't because output has already begun.

Can you show us shop/checkout/index.php in its entirety?

Sure - thanks for you help

<?php include($_SERVER['DOCUMENT_ROOT'].'/Vanilla-CMS/perch/runtime.php');
?>
<!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8" />
    <title>Perch Example Page</title>
    <?php perch_get_css(); ?>
</head>
<body>
    <header class="layout-header">
        <div class="wrapper">
            <div class="company-name">Perch Shop App</div>
            <img src="<?php perch_path('feathers/quill/img/logo.gif'); ?>" alt="Your Logo Here" class="logo"/>
        </div>
        <nav class="main-nav">
            <?php perch_pages_navigation(array(
                    'levels'=>1
                ));
            ?>
        </nav>
    </header>

    <div class="wrapper cols2-nav-right">

        <div class="primary-content">
<?php

             if (!perch_shop_cart_has_property('terms_agreed')) {
                echo '<div class="left-col-checkout">';
                perch_shop_order_addresses();
                perch_shop_form('checkout/confirm.html');
                echo '</div>';
                perch_shop_cart([
                    'template'=>'cart/cart_static.html'
                ]);




             } else { 
              perch_shop_checkout('manual', [
                            'return_url'=>'/Vanilla-CMS/shop/success/index.php',
                            'cancel_url'=>'/Vanilla-CMS/shop/success/index.php',
                            'status'=>'processing'
                          ]);
             }

    ?>

        </div>

        <nav class="sidebar">
            <?php
                if (perch_member_logged_in()) {
            ?>  
                <ul>
                    <li><a href="../../members/profile.php">Edit profile</a></li>
                    <li><a href="../../members/logout.php">Log out</a></li>
                </ul>

            <?php
                }else{
                    perch_members_login_form(); 
                }
            ?>
        </nav>  
    </div>

    <footer class="layout-footer">
        <div class="wrapper">
            <ul class="social-links">
                <li class="twitter"><a href="#" rel="me">Twitter</a></li>
                <li class="facebook"><a href="#" rel="me">Facebook</a></li>
                <li class="flickr"><a href="#" rel="me">Flickr</a></li>
                <li class="linkedin"><a href="#" rel="me">LinkedIn</a></li>
                <li class="rss"><a href="#">RSS</a></li>
            </ul>
            <small>Copyright © <?php echo date('Y'); ?></small>
        </div>
    </footer>

    <?php perch_get_javascript(); ?>
</body>
</html>
Drew McLellan

Drew McLellan 2638 points
Perch Support

You need to call perch_shop_checkout() BEFORE any HTML is output. You've got about 20 lines of HTML being sent before your redirect.

Oooh, I see!

Yep, that was was it! Thanks for your patience and stellar support as always!