I'm using checkout.twig in the CraftCMS shop checkout examples templates.nav checkout astrip

As the user proceeds though the checkout process, this nav strip appears at the top of each page and marks their progress. The nav strip is active and so the user can bypass the shipping section altogether by clicking the "Payment" link at the end and then just pay for the item and not pay any shipping. The shipping doesn't get applied automatically as they should go through to the shipping section and click the shipping option radio button. I would much sooner automatically apply the shipping without them having to select it. Can anyone tell me how to automatically apply shipping and also prevent the user from skipping ahead by clicking the payment button?


1 Answer 1


I fixed this in payment.twig by wrapping the payment form (id="paymentForm") in :

{% if cart.shippingAddress and cart.shippingMethod %}

     //paypal and payment buttons
     <form id="paymentForm">...</form>

{% else %}

          {% if not cart.shippingAddress %}

               <p>No shipping address selected.</p>
               <a href="{{ url('/shop/checkout/addresses') }}">

          {% elseif not cart.shippingMethod %}

               <p>No shipping method.</p>
               <a href="{{ url('/shop/checkout/shipping') }}">

          {% endif %}

{% endif %}

It doesn't make the shipping automatically applied or prevent the user from skipping the shipping charge but it does prevent the user from checking out without going through the correct process.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.