0

When a user proceeds to the checkout page and is not logged-in, it is presented with the form to login or create an account. "Allow guest checkout" is set to no. At this point, the user can log in just fine, but when the "register" button is clicked, the account creation form loads for a second but then the page redirects to the cart. No error messages displayed, no empty cart.

I looked at the browser console and found out that the AJAX call to the checkout/onepage/saveMethod action is failing with a "404 (Not Found)". If I the user is logged in though, the same action is available. I have searched a lot about this and everyone keeps saying that it is fixed by setting "Allow Guest Checkout" to yes, but that is not an option in this case. Someone said here that it should be fixed

by setting “Require Customer To Be Logged In To Checkout” to No

but that also did not work.

Has anyone run into this before?

TL;DR: Allow Guest Checkout is set to No. Customer registration page in Chekout loads and then immediately redirects to the cart. Customer can login succesfully or register outside of the chekout and then place an order. Why is the registration form being redirected if it already loaded? Why is the action checkout/onepage/saveMethod returning a 404 in the ajax call?

  • Have you turned on logging to see if it's throwing an error or Exception? Whenever I've seen Magento jump back to the cart page in the middle of a registration or checkout it was caused by an exception. – seanbreeden Feb 11 '15 at 23:37
  • Yes, and I see no errors related to this at all. The weirdest is that I can access checkout/onepage/saveMethod directly in the browser when I'm logged in. I get a blank page, which is expected. But when there's no customer login then it gives a 404. Some observer somewhere must be intercepting the call before it gets to the action method. – Vic Feb 12 '15 at 19:45
1

I had the same problem with this, and found it only to be a problem when "Login and Pay with Amazon" was enabled. When I turned it off, I was able to click the 'Register' button and not get redirected back to the cart.

However, since I really need the Amazon Login and Pay option, I was able to change a setting in System -> Sales -> Checkout "Require Customer To Be Logged In To Checkout" to "No".

After that, I was able to use the Amazon service AND allow a customer to click "Register" on the first part of the checkout process.

Hope this helps!

1

I had the same problem today and I found out that the problem was caused by a customized version of persistent/checkout/onepage/login.phtml file in my template.

Many changes have been applied over time and I found out that I missed to update my customized phtml file.

Apparently I had a problem with the register button and relative javascript. I had this code

    <div class="buttons-set">
        <p class="required">&nbsp;</p>
        <button type="button" class="button" onclick="checkout.setMethod();"><span><span><?php echo ($this->getQuote()->isAllowedGuestCheckout() ? $this->__('Continue') : $this->__('Register')) ?></span></span></button>
    </div>

New code is:

<div class="buttons-set">
        <p class="required">&nbsp;</p>
        <?php if ($this->getQuote()->isAllowedGuestCheckout()): ?>
            <button id="onepage-guest-register-button" type="button" class="button" onclick="checkout.setMethod();"><span><span><?php echo $this->__('Continue') ?></span></span></button>
        <?php elseif ($this->helper('checkout')->isCustomerMustBeLogged()): ?>
            <button id="onepage-guest-register-button" type="button" class="button" onclick="window.location='<?php echo $this->helper('checkout/url')->getRegistrationUrl();?>'"><span><span><?php echo $this->__('Register') ?></span></span></button>
        <?php else: ?>
            <form action="<?php echo $this->getUrl('persistent/index/saveMethod'); ?>">
                <button id="onepage-guest-register-button" type="submit" class="button"><span><span><?php echo $this->__('Register') ?></span></span></button>
            </form>
        <?php endif; ?>
</div>

and the missing javascript at the end of the page is:

<?php
$registerParam = $this->getRequest()->getParam('register');
if ($registerParam || $registerParam === ''):
?>
<script type="text/javascript">
//<![CDATA[
    document.observe("dom:loaded", function() {
        if($('login:register')) {
            $('login:register').checked = true;
            checkout.setMethod();
        }
    })
//]]>
</script>

So just check app/design/frontend/base/default/template/persistent/checkout/onepage/login.phtml and compare with your login.phtml file.

Hope this helps!

0

I ended up checking if customer is logged in before rendering the checkout page in an event observer. If not logged in, I redirect the user to the customer login page after setting a session variable to indicate that the customer should be redirected to checkout after login.

$session = Mage::getSingleton('customer/session');
if($session->isLoggedIn())
{
     $session->setData('redirect_to_checkout', true);
     Mage::app()->getResponse()->setRedirect(Mage::getUrl('customer/account/login'));
}

Then, after customer is logged in do:

$session = Mage::getSingleton('customer/session');
if($session->getData('redirect_to_checkout'))
{
     $session->unsetData('redirect_to_checkout');
     Mage::app()->getResponse()->setRedirect(Mage::getUrl('checkout/onepage'));
}

I did this because I happend to have made a custom registration form for customers anyways and I couldn't set

System -> Sales -> Checkout "Require Customer To Be Logged In To Checkout" to "No".

-1

Use below code for redirection on checkout page :

$successUrl = $this->_getUrl('checkout/onepage/index', array('_secure' => true));
        if ($this->_getSession()->getBeforeAuthUrl()) {
            $successUrl = $this->_getSession()->getBeforeAuthUrl(true);
        }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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