1

I'm looking remove the "Continue" button on step 1 of Magento Onepage Checkout. I've tried the code at Thinking Magento with no luck.

Rather than a radio button, I'd like the option to be a button itself. Once clicked, the user is moved onto step 2 based on their selection.

Here is the current code in onepage:

<?php if( $this->getQuote()->isAllowedGuestCheckout() ): ?>
        <ul class="form-list">
            <?php if( $this->getQuote()->isAllowedGuestCheckout() ): ?>
            <li class="control">
                <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>
            </li>
            <?php endif; ?>
            <li class="control">
                <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>
            </li>
        </ul>

    <?php else: ?>
        <input type="hidden" name="checkout_method" id="login:register" value="register" checked="checked" />
    <?php endif; ?>
            <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: ?>
            <button type="button" class="button" onclick="checkout.setMethod();"><span><span><?php echo ($this->getQuote()->isAllowedGuestCheckout() ? $this->__('Continue') : $this->__('Register')) ?></span></span></button>
        <?php endif; ?>

And there's the setmethod js:

    setMethod: function(){
    if ($('login:guest') && $('login:guest').checked) {
        this.method = 'guest';
        var request = new Ajax.Request(
            this.saveMethodUrl,
            {method: 'post', onFailure: this.ajaxFailure.bind(this), parameters: {method:'guest'}}
        );
        Element.hide('register-customer-password');
        this.gotoSection('billing', true);
    }
    else if($('login:register') && ($('login:register').checked || $('login:register').type == 'hidden')) {
        this.method = 'register';
        var request = new Ajax.Request(
            this.saveMethodUrl,
            {method: 'post', onFailure: this.ajaxFailure.bind(this), parameters: {method:'register'}}
        );
        Element.show('register-customer-password');
        this.gotoSection('billing', true);
    }
    else{
        alert(Translator.translate('Please choose to register or to checkout as a guest').stripTags());
        return false;
    }
    document.body.fire('login:setMethod', {method : this.method});
},

Curious if anyone has a more updated solution.

1

This is pretty simple, you will just need to change below code in your checkout login.phtml file.

Find the code below

<ul class="form-list">
    <?php if( $this->getQuote()->isAllowedGuestCheckout() ): ?>
    <li class="control">
        <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>
    </li>
    <?php endif; ?>
    <li class="control">
        <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>
    </li>
</ul>

and change it to

<ul class="form-list">
    <?php if( $this->getQuote()->isAllowedGuestCheckout() ): ?>
    <li class="control">
        <button type="button" class="button" onclick="$('login:guest').checked = true;checkout.setMethod();"><span><span><?php echo $this->__('Checkout as Guest') ?></span></span></button>
        <input type="hidden" 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" />
    </li>
    <?php endif; ?>
    <li class="control">
        <button type="button" class="button" onclick="$('login:register').checked = true;checkout.setMethod();"><span><span><?php echo $this->__('Register') ?></span></span></button>
        <input type="hidden" 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" />
    </li>
</ul>

You can remove your continue button from this file.

0

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.