Skip to content

Commit

Permalink
Reduced multiple dispatch events in login form.
Browse files Browse the repository at this point in the history
  • Loading branch information
kiatng committed Sep 10, 2020
1 parent ff4f46a commit b252e49
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,38 +32,40 @@
*/
/** @var $this Mage_Checkout_Block_Onepage_Login */
?>
<?php $isRegistrationAllowed = $this->helper('customer')->isRegistrationAllowed() ?>
<?php $isAllowedGuestCheckout = $this->getQuote()->isAllowedGuestCheckout() ?>
<?php echo $this->getChildHtml('login_before') ?>
<div class="col2-set<?php if (!$this->helper('customer')->isRegistrationAllowed() && !$this->getQuote()->isAllowedGuestCheckout()) echo ' login-only' ?>">
<div class="col2-set<?php if (!$isRegistrationAllowed && !$isAllowedGuestCheckout) echo ' login-only' ?>">
<div class="col-1">
<h3>
<?php if( $this->getQuote()->isAllowedGuestCheckout() && $this->helper('customer')->isRegistrationAllowed() ): ?>
<?php if ($isAllowedGuestCheckout && $isRegistrationAllowed): ?>
<?php echo $this->__('Checkout as a Guest or Register') ?>
<?php elseif ( $this->getQuote()->isAllowedGuestCheckout() && !$this->helper('customer')->isRegistrationAllowed() ): ?>
<?php elseif ($isAllowedGuestCheckout && !$isRegistrationAllowed): ?>
<?php echo $this->__('Checkout as a Guest') ?>
<?php else: ?>
<?php echo $this->__('Register to Create an Account') ?>
<?php endif; ?>
</h3>
<?php if( !$this->getQuote()->isAllowedGuestCheckout() && $this->helper('customer')->isRegistrationAllowed() ): ?>
<?php if (!$isAllowedGuestCheckout && $isRegistrationAllowed): ?>
<p class="description"><?php echo $this->__('Register and save time!') ?></strong><br />
<?php echo $this->__('Register with us for future convenience:') ?></p>
<ul>
<li><?php echo $this->__('Fast and easy check out') ?></li>
<li><?php echo $this->__('Easy access to your order history and status') ?></li>
</ul>
<?php elseif( $this->getQuote()->isAllowedGuestCheckout() && $this->helper('customer')->isRegistrationAllowed() ): ?>
<?php elseif ($isAllowedGuestCheckout && $isRegistrationAllowed): ?>
<p class="description"><?php echo $this->__('Register with us for future convenience:') ?></p>
<?php endif ?>
<?php if( $this->getQuote()->isAllowedGuestCheckout() ): ?>
<?php if ($isAllowedGuestCheckout): ?>
<ul class="form-list">
<?php if( $this->getQuote()->isAllowedGuestCheckout() ): ?>
<?php if ($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_REGISTER): ?> checked="checked"<?php endif; ?> class="radio" /><label for="login:guest"><?php echo $this->__('Checkout as Guest') ?></label>
</li>
<?php endif; ?>
<?php if( $this->helper('customer')->isRegistrationAllowed() ): ?>
<?php if ($isRegistrationAllowed): ?>
<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" />
<input type="radio" name="checkout_method" id="login:register" value="register"<?php if($this->getQuote()->getCheckoutMethod()==Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER || !$isAllowedGuestCheckout): ?> checked="checked"<?php endif ?> class="radio" />
<label for="login:register"><?php echo $this->__('Register and Checkout') ?></label>
</li>
<?php endif; ?>
Expand All @@ -73,7 +75,7 @@
<?php endif; ?>
<div class="buttons-set">
<p class="required">&nbsp;</p>
<?php if ($this->getQuote()->isAllowedGuestCheckout()): ?>
<?php if ($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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@
*/
/** @var $this Mage_Customer_Block_Form_Login */
?>
<div class="account-login<?php if (!$this->helper('customer')->isRegistrationAllowed()) echo ' login-only' ?>">
<?php $isRegistrationAllowed = $this->helper('customer')->isRegistrationAllowed() ?>
<div class="account-login<?php if (!$isRegistrationAllowed) echo ' login-only' ?>">
<div class="page-title">
<h1><?php if ($this->helper('customer')->isRegistrationAllowed()): ?>
<h1><?php if ($isRegistrationAllowed): ?>
<?php echo $this->__('Login or Create an Account') ?>
<?php else: ?>
<?php echo $this->__('Login'); ?>
Expand All @@ -44,7 +45,7 @@
<form action="<?php echo $this->getPostActionUrl() ?>" method="post" id="login-form" class="scaffold-form">
<?php echo $this->getBlockHtml('formkey'); ?>
<div class="col2-set">
<?php if ($this->helper('customer')->isRegistrationAllowed()): ?>
<?php if ($isRegistrationAllowed): ?>
<div class="col-1 new-users">
<div class="content">
<h2><?php echo $this->__('New Here?') ?></h2>
Expand All @@ -61,7 +62,7 @@
</div>
<?php endif; ?>
<?php // This column should be col-1 if the registration column is not displayed ?>
<div class="<?php if ($this->helper('customer')->isRegistrationAllowed()): ?>col-2<?php else: ?>col-1<?php endif; ?> registered-users">
<div class="<?php if ($isRegistrationAllowed): ?>col-2<?php else: ?>col-1<?php endif; ?> registered-users">
<div class="content fieldset">
<h2><?php echo $this->__('Already registered?') ?></h2>
<p class="form-instructions"><?php echo $this->__('If you have an account with us, please log in.') ?></p>
Expand Down

0 comments on commit b252e49

Please sign in to comment.