<logic:if test="\Components\Customers\Contacts::currentIsLoggedIn()">
<h1>Login Information</h1>
<p>You are now logged in as <personalisation:fullname />.</p>
<ul>
<li><a href="[? \Components\Commerce\Carts\Current::getStep() ?]">Proceed with your order</a></li>
<li><standard:link id="commerce_logout" onclickserver="\Components\Customers\Contacts::currentLogout()">Logout, and login or register as someone else</standard:link></li>
</ul>
</logic:if>
<logic:else>
<h1>Checkout</h1>
<p>Select an option:</p>
<forms:form id="commerce_new_customer_method_form">
<forms:row type="one_column">
<ajax:event id="commerce_contact_method_ajaxevent" updateregions="commerce_contact_method_ajaxregion" />
<forms:radiobutton id="commerce_contact_method_register" value="register" label="I'm a New Customer" name="contact_method" valuechecked="register" onclickajax="commerce_contact_method_ajaxevent" savestate="true" /><br />
<forms:radiobutton id="commerce_contact_method_existing" value="register" label="Login as Existing Customer" name="contact_method" valuechecked="login" onclickajax="commerce_contact_method_ajaxevent" savestate="true" /><br />
<logic:if test="!(\Components\Commerce\Carts\Current::getIsGuestCheckoutDisabled())">
<forms:radiobutton id="commerce_contact_method_guest" value="register" label="Guest Checkout" name="contact_method" valuechecked="guest" onclickajax="commerce_contact_method_ajaxevent" savestate="true" /><br />
</logic:if>
</forms:row>
</forms:form>
<ajax:region id="commerce_contact_method_ajaxregion">
<br />
<logic:if test="$commerce_contact_method_existing.checked">
<h2>Login as Existing Customer</h2>
<p>If you already have an account with us, login below.</p>
<forms:form norefresh="true" contactmode="login" autocomplete="off" id="commerce_customers_contacts_login">
<forms:row label="E-mail Address">
<forms:editbox id="commerce_contact_email" datacolumn="contact_email" validations="mandatory" transformations="tolower" value="[? \Components\Customers\Contacts::currentGetColumn('contact_email') ?]" />
</forms:row>
<forms:row label="Password">
<forms:password id="commerce_contact_password" datacolumn="contact_password" validations="mandatory" />
</forms:row>
<forms:row type="one_column" align="center">
<forms:submitbutton>Login</forms:submitbutton>
</forms:row>
</forms:form>
<small><a href="/community/lost_password/">Lost Password</a></small>
</logic:if>
<logic:if test="($commerce_new_customer_method_form.getValueForFormItem('contact_method') == 'register') || ($commerce_new_customer_method_form.getValueForFormItem('contact_method') == 'guest')">
<h2>Your Details</h2>
<p>Please enter your details into the form below:</p>
<forms:form id="commerce_community_register_form" contactmode="register" onsubmitserver="\Components\Commerce\Carts\Current::setContactShouldInvoiceCompany($commerce_invoice_to_company.checked)" onsubmitredirect="[? \Components\Commerce\Carts\Current::getStep(true, false, false) ?]">
<ajax:event id="commerce_invoice_to_ajaxevent" updateregions="commerce_invoice_to_ajaxregion" />
<forms:row label="Invoice To">
<forms:radiobutton id="commerce_invoice_to_individual" onclickajax="commerce_invoice_to_ajaxevent" name="commerce_invoice_to" label="Individual" valuechecked="Individual" value="Individual" />
<forms:radiobutton id="commerce_invoice_to_company" onclickajax="commerce_invoice_to_ajaxevent" name="commerce_invoice_to" label="Company" valuechecked="Company" value="Individual" />
</forms:row>
<ajax:region id="commerce_invoice_to_ajaxregion">
<logic:if test="$commerce_invoice_to_company.checked">
<forms:row label="Company Name">
<forms:editbox id="commerce_contact_company" datacolumn="contact_company" validations="mandatory" />
</forms:row>
</logic:if>
</ajax:region>
<forms:row label="Your Name">
<forms:editbox id="commerce_contact_first_name" datacolumn="contact_first_name" width="30%" validations="mandatory" placeholder="First name" />
<forms:editbox id="commerce_contact_last_name" datacolumn="contact_last_name" width="40%" validations="mandatory" placeholder="Last name" />
</forms:row>
<forms:row label="E-mail Address">
<forms:editbox datacolumn="contact_email" validations="mandatory,email" id="commerce_contact_email" />
</forms:row>
<forms:row label="Subscribe to receive our e-mail newsletter.">
<forms:checkbox id="contact_email_marketing_status" valuechecked="subscribed" valueunchecked="pending" label="Subscribe to receive our e-mail newsletter." value="pending"/>
</forms:row>
<logic:variable as="ipcountry" value="[? \Framework\HTTP\Request::getCountryCodeFromIP() ?]" />
<forms:row label="Address">
<forms:textarea id="commerce_contact_address" datacolumn="contact_address" validations="mandatory" rows="2" />
</forms:row>
<forms:row label="Suburb / City">
<forms:editbox id="commerce_contact_suburb_city" datacolumn="contact_suburb_city" validations="mandatory" />
</forms:row>
<forms:row label="State / Province / Territory">
<forms:editbox id="commerce_contact_state" value="[? \Framework\Network\GeoIP::getRegion(\Framework\HTTP\Request::getIP()) ?]" datacolumn="contact_state" validations="mandatory" autocompletedatasource="\Framework\I18N\Countries::getStateTitlesFlat($ipcountry)" />
</forms:row>
<forms:row label="Postcode / ZIP Code">
<forms:editbox id="commerce_contact_postcode" datacolumn="contact_postcode" validations="mandatory" width="80" />
</forms:row>
<forms:row label="Country">
<forms:combobox id="commerce_country_id" as="country" value="[? $ipcountry ?]" datacolumn="country_id" datatitle="$country['country_title']" datavalue="$country['country_id']" datasource="\Framework\I18N\Countries::getAll()" />
</forms:row>
<forms:row label="Contact Phone">
<forms:editbox id="commerce_contact_phone" datacolumn="contact_phone" validations="mandatory,phonenumber" />
</forms:row>
<synergy8:customfieldsrenderer fields="[? \Components\Customers\Contacts::fieldsCustomGetAllExt(null, null, null, [['field_is_shown_in_checkout', '=', 1]]) ?]" />
<logic:if test="($commerce_new_customer_method_form.getValueForFormItem('contact_method') == 'register')">
<forms:row label="Account Password" description="Set a password so you can return to this site later.">
<forms:password id="commerce_contact_password" datacolumn="contact_password" validations="mandatory" />
</forms:row>
</logic:if>
<forms:row align="center" type="one_column">
<forms:submitbutton>Continue ></forms:submitbutton>
</forms:row>
</forms:form>
</logic:if>
</ajax:region>
</logic:else>
<logic:if test="\Components\Customers\Contacts::currentIsLoggedIn()">
<h1>Login Information</h1>
<p>You are now logged in as <personalisation:fullname />.</p>
<ul>
<li><a href="[? \Components\Commerce\Carts\Current::getStep() ?]">Proceed with your order</a></li>
<li><standard:link id="commerce_logout" onclickserver="\Components\Customers\Contacts::currentLogout()">Logout, and login or register as someone else</standard:link></li>
</ul>
</logic:if>
<logic:else>
<h1>Checkout</h1>
<p>Select an option:</p>
<forms:form id="commerce_new_customer_method_form">
<forms:row type="one_column">
<ajax:event id="commerce_contact_method_ajaxevent" updateregions="commerce_contact_method_ajaxregion" />
<forms:radiobutton id="commerce_contact_method_register" value="register" label="I'm a New Customer" name="contact_method" valuechecked="register" onclickajax="commerce_contact_method_ajaxevent" savestate="true" /><br />
<forms:radiobutton id="commerce_contact_method_existing" value="register" label="Login as Existing Customer" name="contact_method" valuechecked="login" onclickajax="commerce_contact_method_ajaxevent" savestate="true" /><br />
<logic:if test="!(\Components\Commerce\Carts\Current::getIsGuestCheckoutDisabled())">
<forms:radiobutton id="commerce_contact_method_guest" value="register" label="Guest Checkout" name="contact_method" valuechecked="guest" onclickajax="commerce_contact_method_ajaxevent" savestate="true" /><br />
</logic:if>
</forms:row>
</forms:form>
<ajax:region id="commerce_contact_method_ajaxregion">
<br />
<logic:if test="$commerce_contact_method_existing.checked">
<h2>Login as Existing Customer</h2>
<p>If you already have an account with us, login below.</p>
<forms:form norefresh="true" contactmode="login" autocomplete="off" id="commerce_customers_contacts_login">
<forms:row label="E-mail Address">
<forms:editbox id="commerce_contact_email" datacolumn="contact_email" validations="mandatory" transformations="tolower" value="[? \Components\Customers\Contacts::currentGetColumn('contact_email') ?]" />
</forms:row>
<forms:row label="Password">
<forms:password id="commerce_contact_password" datacolumn="contact_password" validations="mandatory" />
</forms:row>
<forms:row type="one_column" align="center">
<forms:submitbutton>Login</forms:submitbutton>
</forms:row>
</forms:form>
<small><a href="/community/lost_password/">Lost Password</a></small>
</logic:if>
<logic:if test="($commerce_new_customer_method_form.getValueForFormItem('contact_method') == 'register') || ($commerce_new_customer_method_form.getValueForFormItem('contact_method') == 'guest')">
<h2>Your Details</h2>
<p>Please enter your details into the form below:</p>
<forms:form id="commerce_community_register_form" contactmode="register" onsubmitserver="\Components\Commerce\Carts\Current::setContactShouldInvoiceCompany($commerce_invoice_to_company.checked)" onsubmitredirect="[? \Components\Commerce\Carts\Current::getStep(true, false, false) ?]">
<ajax:event id="commerce_invoice_to_ajaxevent" updateregions="commerce_invoice_to_ajaxregion" />
<forms:row label="Invoice To">
<forms:radiobutton id="commerce_invoice_to_individual" onclickajax="commerce_invoice_to_ajaxevent" name="commerce_invoice_to" label="Individual" valuechecked="Individual" value="Individual" />
<forms:radiobutton id="commerce_invoice_to_company" onclickajax="commerce_invoice_to_ajaxevent" name="commerce_invoice_to" label="Company" valuechecked="Company" value="Individual" />
</forms:row>
<ajax:region id="commerce_invoice_to_ajaxregion">
<logic:if test="$commerce_invoice_to_company.checked">
<forms:row label="Company Name">
<forms:editbox id="commerce_contact_company" datacolumn="contact_company" validations="mandatory" />
</forms:row>
</logic:if>
</ajax:region>
<forms:row label="Your Name">
<forms:editbox id="commerce_contact_first_name" datacolumn="contact_first_name" width="30%" validations="mandatory" placeholder="First name" />
<forms:editbox id="commerce_contact_last_name" datacolumn="contact_last_name" width="40%" validations="mandatory" placeholder="Last name" />
</forms:row>
<forms:row label="E-mail Address">
<forms:editbox datacolumn="contact_email" validations="mandatory,email" id="commerce_contact_email" />
</forms:row>
<forms:row label="Subscribe to receive our e-mail newsletter.">
<forms:checkbox id="contact_email_marketing_status" valuechecked="subscribed" valueunchecked="pending" label="Subscribe to receive our e-mail newsletter." value="pending"/>
</forms:row>
<logic:variable as="ipcountry" value="[? \Framework\HTTP\Request::getCountryCodeFromIP() ?]" />
<forms:row label="Address">
<forms:textarea id="commerce_contact_address" datacolumn="contact_address" validations="mandatory" rows="2" />
</forms:row>
<forms:row label="Suburb / City">
<forms:editbox id="commerce_contact_suburb_city" datacolumn="contact_suburb_city" validations="mandatory" />
</forms:row>
<forms:row label="State / Province / Territory">
<forms:editbox id="commerce_contact_state" value="[? \Framework\Network\GeoIP::getRegion(\Framework\HTTP\Request::getIP()) ?]" datacolumn="contact_state" validations="mandatory" autocompletedatasource="\Framework\I18N\Countries::getStateTitlesFlat($ipcountry)" />
</forms:row>
<forms:row label="Postcode / ZIP Code">
<forms:editbox id="commerce_contact_postcode" datacolumn="contact_postcode" validations="mandatory" width="80" />
</forms:row>
<forms:row label="Country">
<forms:combobox id="commerce_country_id" as="country" value="[? $ipcountry ?]" datacolumn="country_id" datatitle="$country['country_title']" datavalue="$country['country_id']" datasource="\Framework\I18N\Countries::getAll()" />
</forms:row>
<forms:row label="Contact Phone">
<forms:editbox id="commerce_contact_phone" datacolumn="contact_phone" validations="mandatory,phonenumber" />
</forms:row>
<synergy8:customfieldsrenderer fields="[? \Components\Customers\Contacts::fieldsCustomGetAllExt(null, null, null, [['field_is_shown_in_checkout', '=', 1]]) ?]" />
<logic:if test="($commerce_new_customer_method_form.getValueForFormItem('contact_method') == 'register')">
<forms:row label="Account Password" description="Set a password so you can return to this site later.">
<forms:password id="commerce_contact_password" datacolumn="contact_password" validations="mandatory" />
</forms:row>
</logic:if>
<forms:row align="center" type="one_column">
<forms:submitbutton>Continue ></forms:submitbutton>
</forms:row>
</forms:form>
</logic:if>
</ajax:region>
</logic:else>