I am trying to separate the "Create new Account" and "Checkout as Guest" options into two columns, so my checkout login will feature three separate columns: "Checkout as Guest", "Create new Account", "Login to existing Account". For this to work, I need to remove the radio buttons and add the setMethod function to the buttons. Will this require changing the function itself in opcheckout.js
, or can this be achieved by editing the login template?
1 Answer
I found this guide and tried following it step by step without any luck. I then tried adding the modified setMethod function to opcheckout_rwd.js instead of opcheckout.js and it seems to be working now.
This is the code I am inserting into opcheckout_rwd.js:
Checkout.prototype.setMethod = function (methodtype) {
if (methodtype=='guest') {
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');
}
else if(methodtype=='register') {
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');
}
else {
alert(Translator.translate('Please choose to register or to checkout as a guest'));
return false;
} }
The edits to login.phtml can be adapted from the guide. The only concern I am having right now, is that I am not sure if this breaks support for persistent carts since I had to remove this entire part from login.phtml:
<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>
to prevent having the button load the billing step with ®ister added to the url (see here). I am not using persistent carts so it is not an issue for me...