Magento – opcheckout.js – setMethod undefined onClick

onepage-checkout

I re-styled the Code in my login.phtml (onepage checkout) and now the "continue"-button does not work. Console outputs "Uncaught TypeError: Cannot read property 'setMethod' of undefined"

opcheckout.js doesnt seem to need defined classnames and I used basically the markup of the original login.phtml. What did I do wrong?

        <div class="column half">
        <h4><?php if( $this->getQuote()->isAllowedGuestCheckout() ): ?><?php echo $this->__('Checkout as a Guest or Register') ?><?php else: ?><?php echo $this->__('Register to Create an Account') ?><?php endif; ?></h4>
        <p><?php echo $this->__('Register with us for future convenience:') ?></p>

        <?php if( $this->getQuote()->isAllowedGuestCheckout() ): ?>
        <input type="radio" name="checkout_method" id="login:guest" value="guest"<?php if($this->getQuote()->getCheckoutMethod()==Mage_Checkout_Model_Type_Onepage::METHOD_GUEST): ?> checked="checked"<?php endif; ?> class="radio" />
        <label for="login:guest"><?php echo $this->__('Checkout as Guest') ?></label>
        <br />
        <?php endif; ?>

        <input type="radio" name="checkout_method" id="login:register" value="register"<?php if($this->getQuote()->getCheckoutMethod()==Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER || !$this->getQuote()->isAllowedGuestCheckout()): ?> checked="checked"<?php endif ?> class="radio" /><label for="login:register"><?php echo $this->__('Register') ?></label>


        <input type="hidden" name="checkout_method" id="login:register" value="register" checked="checked" />


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

    </div>

Best Answer

Is that the only template you've modified?

The checkout object is an instance of Checkout and is instantiated in app/design/frontend/[base|rwd]/default/template/checkout/onepage.phtml. Have you made any changes to this file that would have caused that problem?

It could also be a syntax error in that template or another that is killing the block rendering process before it comes back around to onepage.phtml. View the page source and see if you get a complete HTML document.

See also app/design/frontend/[base|rwd]/default/layout/checkout.xml under the checkout_onepage_index handle for all of the blocks and templates that might have syntax errors and so cause rendering to end prematurely.