Startseite > Template- und Themeprogrammierung > Checkout- & Order-Templates > checkout / login.liquid

login.liquid

Das Template <keyword>login.liquid</keyword> rendert den Login-Step des Checkout-Workflows.

Speicherort

Das Template muss unter <keyword>templates/checkout/login.liquid</keyword> abgelegt werden.

Verfügbare Objekte

Innerhalb des <keyword>login.liquid</keyword> Templates stehen folgende Objekte zur Verfügung:

  • globale Objekte
  • <obj>cart</obj>
  • <obj>checkout_workflow:workflow#step-1</obj>

Beispiel

Das nachfolgend Beispiel zeigt die Ausgabe des Formulars für die Anmeldung für registrierte Kunden und das Formular für den Einstieg von Neukunden.

<h2>Sign in</h2>

{% assign login_form = workflow.current_step.forms.login  %}
<form method="post" action="{{ login_form.action }}">
  
  {% unless login_form.valid %}
    <b>There are errors in this form.</b>
  {% endunless %}
  
  {% comment %}Field for username or email{% endcomment %}
  <label for="{{ login_form.fields.user_name.name }}">
    {% if shop.config.login_is_email == 1 %}E-Mail{% else %}Username{% endif %}
  </label>
  <input type="{% if shop.config.login_is_email == 1 %}email{% else %}text{% endif %}"
         {% if login_form.fields.user_name.required %}required{% endif %}
         {% if login_form.fields.user_name.max_length %}maxlength="{{ login_form.fields.user_name.max_length }}"{% endif %}
         name="{{ login_form.fields.user_name.name }}"
         value="{{ login_form.fields.user_name.value }}" />
  
  {% comment %}Field for password{% endcomment %}
  <label for="{{ login_form.fields.password.name }}">
    Password
  </label>
  <input type="{{ login_form.fields.password.type }}"
         {% if login_form.fields.password.required %}required{% endif %}
         {% if login_form.fields.password.max_length %}maxlength="{{ login_form.fields.password.max_length }}"{% endif %}
         name="{{ login_form.fields.password.name }}"
         value="" />
  
  {% comment %}Submit-Button{% endcomment %}
  <input type="submit" value="Login">
</form>

<h2>New customer</h2>

{% assign customer_form = workflow.current_step.forms.customer  %}
<form method="post" action="{{ customer_form.action }}">
  
  {% unless customer_form.valid %}
    <b>There are errors in this form.</b>
  {% endunless %}

  <ul>
    <li>
      <label for="{{ customer_form.fields.first_name.name }}">First name</label>
      <input type="{{ customer_form.fields.first_name.type }}"
         {% if customer_form.fields.first_name.required %}required{% endif %}
         {% if customer_form.fields.first_name.max_length %}maxlength="{{ customer_form.fields.first_name.max_length }}"{% endif %}
         name="{{ customer_form.fields.first_name.name }}"
         value="{{ customer_form.fields.first_name.value }}" />
    </li>
    <li>
      <label for="{{ customer_form.fields.last_name.name }}">Last name</label>
      <input type="{{ customer_form.fields.last_name.type }}"
         {% if customer_form.fields.last_name.required %}required{% endif %}
         {% if customer_form.fields.last_name.max_length %}maxlength="{{ customer_form.fields.last_name.max_length }}"{% endif %}
         name="{{ customer_form.fields.last_name.name }}"
         value="{{ customer_form.fields.last_name.value }}" />
    </li>
    <li>
      <label for="{{ customer_form.fields.zip.name }}">Zip</label>
      <input type="{{ customer_form.fields.zip.type }}"
         {% if customer_form.fields.zip.required %}required{% endif %}
         {% if customer_form.fields.zip.max_length %}maxlength="{{ customer_form.fields.zip.max_length }}"{% endif %}
         name="{{ customer_form.fields.zip.name }}"
         value="{{ customer_form.fields.zip.value }}" />
    </li>
    <li>
      <label for="{{ customer_form.fields.city.name }}">City</label>
      <input type="{{ customer_form.fields.city.type }}"
             {% if customer_form.fields.city.required %}required{% endif %}
             {% if customer_form.fields.city.max_length %}maxlength="{{ customer_form.fields.city.max_length }}"{% endif %}
             name="{{ customer_form.fields.city.name }}"
             value="{{ customer_form.fields.city.value }}" />
    </li>
    <li>
      <label for="{{ customer_form.fields.line2.name }}">Street</label>
      <input type="{{ customer_form.fields.line2.type }}"
             {% if customer_form.fields.line2.required %}required{% endif %}
             {% if customer_form.fields.line2.max_length %}maxlength="{{ customer_form.fields.line2.max_length }}"{% endif %}
             name="{{ customer_form.fields.line2.name }}"
             value="{{ customer_form.fields.line2.value }}" />
    </li>
    <li>
      <label for="{{ customer_form.fields.email.name }}">E-Mail</label>
      <input type="{{ customer_form.fields.email.type }}"
         {% if customer_form.fields.email.required %}required{% endif %}
         {% if customer_form.fields.email.max_length %}maxlength="{{ customer_form.fields.email.max_length }}"{% endif %}
         name="{{ customer_form.fields.email.name }}"
         value="{{ customer_form.fields.email.value }}" />
    </li>
    <li>
      <label for="{{ customer_form.fields.country.name }}">Country</label>
      <select name="{{ customer_form.fields.country.name }}">
        {% for option in customer_form.fields.country.options %}
          <option value="{{ option.value }}" {% if otpion.selected %}selected{% endif %}>{{ option.name }}</option>
        {% endfor %}
      </select>
    </li>
  </ul>
  
  {% comment %}Submit-Button{% endcomment %}
  <input type="submit" value="Continue">
</form>