Forum

Thread tagged as: Question, Shop

Condition for delivery step

I want create "delivery step". Step 1 -> address / step 2 -> choose delivery / step 3 -> confirm

any idea what condition I can use in a checkout flow? Something similar to a confrimation step here https://docs.grabaperch.com/addons/shop/examples/order-confirmation

Or maybe is there a way to switch off "delivery" until the user will choose it in the step 2?


<?php if (!perch_member_logged_in()) { echo '<div class="left-col-checkout">'; // New customer sign up form perch_shop_registration_form([ 'template' => 'checkout/customer_create_passwordless.html' ]); echo '</div>'; perch_shop_cart([ 'template'=>'cart/cart_static.html' ]); } elseif (??? Some condition ???) { echo '<div class="left-col-checkout">'; // New customer sign up form perch_shop_order_addresses(); perch_shop_shipping_options(); perch_shop_shipping_method_form(); echo '</div>'; perch_shop_cart([ 'template'=>'cart/cart_static.html' ]); } else { if (!perch_shop_cart_has_property('terms_agreed')) { // Show the order addresses perch_shop_order_addresses(); // Show the cart with a non-interactive template perch_shop_cart([ 'template'=>'cart/cart_static.html' ]); // Display the form with the T&Cs checkbox perch_shop_form('checkout/confirm.html'); }else{ // T&Cs are agreed, so on to the payment step! // your 'success' return URL $return_url = 'https://../'; $cancel_url = 'https://../'; perch_shop_checkout('paypal-express', [ 'return_url' => $return_url, 'cancel_url' => $cancel_url, ]); } } ?>
Maciej Pieńczewski

Maciej Pieńczewski 0 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

That should be fine - which part are you struggling with?

if (perch_member_logged_in())

Should work for you - that is what I am using anyway! There is also

if (perch_shop_addresses_set()) 

Thanks Mike,

this is what I thought about also, but after that how do You go to step 3? What condition do You use after step 2? If I will use

if (perch_member_logged_in())

I will get what I want, but, now comes another question, how from that point go to step 3 (confirmation/payment page)

Ok I haven't tested this but give this a go:

if (!perch_member_logged_in()) {
//Customer create form
}
elseif (perch_member_logged_in() && !perch_shop_cart_has_property('shipping_set')) {
// Shipping Method Form with hidden shipping_set cart property input
}
elseif (perch_shop_cart_has_property('shipping_set') && !perch_shop_cart_has_property('terms_agreed'))
// Terms and Conditions form
}
else {
// Checkout
}