Forum

Thread tagged as: Question, Docs, Shop

Shipping form and checkout flow

https://nlms.ptwclients.com/shop/

I am working with the Perch Shop app, using vanilla Perch (not runway), I am having trouble figuring out the intended checkout flow. I am using Stripe as the payment gateway.

Within shop form templates what is the purpose of <perch:input type="hidden" id="r" /> ?

How do I pass checkout info through multiple forms on different pages?

I have two checkout pages, the first page would allow the user to select a shipping method if they are logged in, or log in/register if they are not. On the next page they review their order and pay with stripe. I can't figure out how to move from step 1 to step 2, the shipping method selection form submits to it's own page.

Here is the first checkout page (/shop/checkout/index.php):

<?php
include_once('../../edit/runtime.php');
$title="";
$meta_desc="";
$meta_keywords="";
include_once('../../includes/header.php');
?>      
<div class="cwrap"> 

  <div class="container">
    <?php
            include_once('../../includes/user-nav.php');

            if (perch_member_logged_in()) {
                perch_shop_shipping_options();

                perch_shop_shipping_method_form();
            } else {
                perch_shop_login_form();

                perch_shop_registration_form();
            }

        ?>
  </div>

</div>
<?php
include_once('../../includes/footer.php');
?>

and the second checkout page (/shop/checkout/review.php):

<?php
include_once('../../edit/runtime.php');
if (perch_member_logged_in() && perch_post('stripeToken')) {
    // your 'success' and 'failure' URLs
    $return_url = '/checkout/confirm.php';
    $cancel_url = '/checkout/error.php';

    perch_shop_checkout('stripe', array(
        'return_url' => $return_url,
        'cancel_url' => $cancel_url,
        'token'      => perch_post('stripeToken')
    )); 
}
$title="";
$meta_desc="";
$meta_keywords="";
include_once('../../includes/header.php');
?>      
<div class="cwrap"> 

  <div class="container">
    <?php
            include_once('../../includes/user-nav.php');

            if (perch_member_logged_in()) { 
                if (!perch_shop_addresses_set()) {
                    perch_shop_order_address_form();
                } else {
                    perch_shop_order_addresses();
                }

                perch_shop_cart(array(
            'template'=>'cart/cart_static.html'
                ));

                if (perch_shop_cart_has_property('terms_agreed')) {
                    perch_shop_payment_form('stripe');
                } else {
                    perch_shop_form('checkout/confirm.html');
                }
            } else {
                PerchSystem::redirect('/shop/cart.php');
            }

        ?>
  </div>

</div>
<?php
include_once('../../includes/footer.php');
?>

Is there an intended checkout flow?

Should the shipping method form actually appear on the cart page?

Does the user select their own shipping method and tax locations, or is the system meant to infer that from their account info at some point?

Also, looking through the shop docs, and the Nest Running Club example site, it seems like their are some page functions, such as perch_shop_form(); that are not explicitly included in the documentation, only in the Nest Running Club code. Understandable, as the Shop App was just released, but it does make it hard to infer the best way to set up a shop that sells physical goods.

Evan Dobos

Evan Dobos 0 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

After the first step, the user should then be logged in, so you can test for that.

if (perch_member_logged_in()) {
    PerchSystem::redirect('/step2');
}

There's no intended flow as such - the idea is you can put the functionality together as you need it.