AgPerry's picture
Add files using upload-large-folder tool
d259c1a verified
Raw History Blame Contribute Delete
5.7 kB
{% extends "base.html" %}
{% block title %}Checkout{% endblock %}
{% block page_id %}checkout{% endblock %}
{% block content %}
<div class="shell">
<h1 class="page-title">Checkout</h1>
<ol class="checkout-steps">
<li class="step is-active">1. Fulfillment &amp; address</li>
<li class="step">2. Review &amp; payment</li>
<li class="step">3. Confirmation</li>
</ol>
<div class="checkout-layout">
<form class="checkout-form" action="/checkout/review" method="post" novalidate>
<section class="checkout-card">
<h2>Contact</h2>
<label>Email for order updates
<input type="email" name="email" required value="{{ form_values.get('email', email_prefill) }}"
class="{{ 'input-error' if field_errors.get('email') }}">
</label>
{% if field_errors.get('email') %}<p class="field-error">{{ field_errors['email'] }}</p>{% endif %}
</section>
<section class="checkout-card">
<h2>How do you want it?</h2>
{% set chosen = form_values.get('fulfillment', 'pickup') %}
<label class="fulfill-choice">
<input type="radio" name="fulfillment" value="pickup" {{ 'checked' if chosen == 'pickup' }}>
<span><strong>Free store pickup</strong> at {{ store.name }}, {{ store.address }}, {{ store.city }} {{ store.zip }} &middot; <a href="/store-locator">change store</a></span>
</label>
<label class="fulfill-choice">
<input type="radio" name="fulfillment" value="delivery" {{ 'checked' if chosen == 'delivery' }}>
<span><strong>Home delivery</strong> &mdash; free over $50, otherwise $9.99</span>
</label>
</section>
<section class="checkout-card">
<h2>{{ 'Billing address' }}</h2>
{% if address_book %}
<details class="addr-book" {{ 'open' if not form_values }}>
<summary>Use a saved address</summary>
{% for a in address_book %}
<button class="btn btn-ghost addr-fill" type="button"
data-addr='{{ {"full_name": a.full_name, "line1": a.line1, "line2": a.line2 or "", "city": a.city, "state": a.state, "zip": a.zip, "phone": a.phone or ""}|tojson }}'>
{{ a.label }}: {{ a.line1 }}, {{ a.city }} {{ a.state }} {{ a.zip }}{{ ' (default)' if a.is_default }}
</button>
{% endfor %}
</details>
{% endif %}
<div class="form-grid">
<label>Full name
<input name="full_name" required value="{{ form_values.get('full_name', default_addr.full_name if default_addr else '') }}" class="{{ 'input-error' if field_errors.get('full_name') }}">
{% if field_errors.get('full_name') %}<span class="field-error">{{ field_errors['full_name'] }}</span>{% endif %}
</label>
<label>Street address
<input name="line1" required value="{{ form_values.get('line1', default_addr.line1 if default_addr else '') }}" class="{{ 'input-error' if field_errors.get('line1') }}">
{% if field_errors.get('line1') %}<span class="field-error">{{ field_errors['line1'] }}</span>{% endif %}
</label>
<label>Apt / suite (optional)
<input name="line2" value="{{ form_values.get('line2', default_addr.line2 if default_addr else '') }}">
</label>
<label>City
<input name="city" required value="{{ form_values.get('city', default_addr.city if default_addr else '') }}" class="{{ 'input-error' if field_errors.get('city') }}">
{% if field_errors.get('city') %}<span class="field-error">{{ field_errors['city'] }}</span>{% endif %}
</label>
<label>State
{% set state_value = form_values.get('state', default_addr.state if default_addr else '') %}
<select name="state" required class="{{ 'input-error' if field_errors.get('state') }}">
<option value="">Choose&hellip;</option>
{% for st in US_STATES %}<option value="{{ st }}" {{ 'selected' if state_value == st }}>{{ st }}</option>{% endfor %}
</select>
{% if field_errors.get('state') %}<span class="field-error">{{ field_errors['state'] }}</span>{% endif %}
</label>
<label>ZIP code
<input name="zip" required inputmode="numeric" maxlength="5" value="{{ form_values.get('zip', default_addr.zip if default_addr else '') }}" class="{{ 'input-error' if field_errors.get('zip') }}">
{% if field_errors.get('zip') %}<span class="field-error">{{ field_errors['zip'] }}</span>{% endif %}
</label>
<label>Phone (optional)
<input name="phone" value="{{ form_values.get('phone', default_addr.phone if default_addr else '') }}">
</label>
</div>
<p class="form-hint">Tax is estimated from the state you choose. Delivery uses this address; pickup uses it for the payment record only.</p>
</section>
<button class="btn btn-red btn-lg" type="submit">Continue to review</button>
</form>
<aside class="cart-summary" aria-label="Order summary">
<h2>Order Summary</h2>
<ul class="mini-lines">
{% for item in totals['items'] %}
<li><span>{{ item.quantity }} &times; {{ item.product.name }}</span><span>{{ money(item.line_total_minor) }}</span></li>
{% endfor %}
</ul>
<dl class="summary-lines">
<div><dt>Subtotal</dt><dd>{{ money(totals.subtotal_minor) }}</dd></div>
{% if totals.discount_minor %}<div class="discount"><dt>Promo savings</dt><dd>&minus;{{ money(totals.discount_minor) }}</dd></div>{% endif %}
<div><dt>Delivery</dt><dd>{{ money(totals.shipping_minor) if totals.shipping_minor else 'Free' }}</dd></div>
<div><dt>Tax</dt><dd>Next step</dd></div>
</dl>
</aside>
</div>
</div>
{% endblock %}