Checkout as Guest button on Cart step

I put 2 pseudo “fast payment” buttons on the “cart” step

  • One for Paypal
  • One for Apple Pay
    Form action for the 2 buttons is :

Like the “continue as guest” form button at the “Account” step

But from the “Cart” step the page is reloaded with a 302/redirection.

Il seems to me this action/URL cannot work from the “Cart” step because

  • it works from the “Account” step (“checkout as guest”)
  • it works if I go to the “Account step” (“continue to Checkout”) and go back to the “Cart” sept and click on one of them.

Maybe a cookie is put to check the previous step ?
Screenshot from 2021-10-06 18-40-44

How can I do to allow the “checkout as quest” action (/shop/purchase/checkout/?step=address) on the “Cart” step ?

The checkout post parameter is required to turn the session order into one that’s saved to the database (which is needed for the account and subsequent steps).

With checkout = 1 the next step is not “address” like the “guest checkout”.

                <form id="form-asguest" class="" action="shop/purchase/checkout/?step=address" method="post">
                    {# apple pay button #}
                    <input type="hidden" name="checkout" value="1">
                    <button id="account_asguest_apay" type="submit" class="{#c-button c-primary-button#} btn btn-black btn btn-lg w-100 mt-0 fw-medium">Buy with <img style="height:24px;" class="img-fluid" src="/assets/project/urbanspree/gfx/payments/apple-pay-white_320px.png"></button>
                    {# paypal button #}
                    <button id="account_asguest_pp" type="submit" class="{#c-button c-primary-button#} btn btn-warning btn btn-lg w-100 mt-2 fw-medium"><img style="height:24px;" class="img-fluid" src="/assets/project/urbanspree/gfx/payments/checkout-paypal.png"></button>

I’d like these button acts like the “Checkout as guest” but early, on the “cart” step

<form id="form-asguest" action="shop/purchase/checkout/?step=account" method="post">
                    <input type="hidden" name="set_guest_checkout" value="1">
                    <button id="account_asguest" type="submit" class=" btn btn-black w-100 mt-4 btn-lg text-uppercase fw-medium">Checkout as guest</button>

If I simply copy/paste this form with the set_guest_checkout = 1 or checkout = 1 param and “shop/purchase/checkout/?step=address&xpck_lang=en” as action it doesn’t work on the “cart” step, there is a 302 to shop/purchase/checkout/?step=cart

Maybe because the “checkout as guest” function is only available on when the “account” step is reached ?

Correct. Only the account step handles set_guest_checkout, and because you haven’t yet POSTed checkout=1 to the cart you do not yet have access to the account step, so it redirects back to the cart without performing any actions.

I’m not sure if I understand correctly what you’re trying to accomplish, but you can just remove the account step from the checkout entirely by changing 2 settings if you want all users to checkout as guest.

(In that case, if a user is logged in before they arrive in the checkout, that still registers the order to their account; they just don’t have the option to login in the checkout itself.)