{include file="_partials/head.tpl"}

<div class="bz-container">
  <div class="bz-page-head">
    <div class="bz-breadcrumbs"><a href="/">Главная</a> · <a href="/cart">Корзина</a> · <span>Оформление заказа</span></div>
    <h1>Оформление заказа</h1>
  </div>

  [if {error}="csrf"]<div class="bz-alert error">Сессия истекла. Перезагрузите страницу.</div>[/if]
  [if {error}="invalid"]<div class="bz-alert error">Проверьте имя и email.</div>[/if]
  [if {error}="empty"]<div class="bz-alert error">Корзина пуста.</div>[/if]
  [if {error}="items"]<div class="bz-alert error">Некоторые товары в корзине недоступны. Обновите корзину.</div>[/if]

  <div class="bz-cart-layout">
    <form method="post" action="/checkout" class="bz-comments" style="margin:0" data-checkout-form>
      {csrf}

      <h2>Контакты</h2>
      <div class="bz-comment-form" style="margin-top:0">
        <div class="bz-row">
          <input type="text" name="name" value="{user.name}" placeholder="Имя" required>
          <input type="email" name="email" value="{user.email}" placeholder="Email" required>
        </div>
        <input type="tel" name="phone" placeholder="Телефон">

        <h2 style="margin-top:24px">Доставка</h2>
        [if {has_shipping}="1"]
          <div class="bz-radio-group">
            [foreach var="shipping_methods" as="m"]
              <label class="bz-radio">
                <input type="radio" name="shipping_method_id" value="{m.id}" [if {_first}="1"]checked[/if] data-cost="{m.cost}">
                <span class="bz-radio__body">
                  <span class="bz-radio__title">{m.title}</span>
                  [if {m.description}]<span class="bz-radio__desc">{m.description}</span>[/if]
                </span>
                <span class="bz-radio__price">[if {m.is_free}]бесплатно[else]{m.cost_fmt}[/if]</span>
              </label>
            [/foreach]
          </div>
        [else]
          <p class="bz-muted">Способы доставки не настроены администратором.</p>
        [/if]
        <textarea name="address" rows="2" placeholder="Адрес доставки"></textarea>

        <h2 style="margin-top:24px">Оплата</h2>
        [if {has_payments}="1"]
          <div class="bz-radio-group">
            [foreach var="payment_methods" as="p"]
              <label class="bz-radio">
                <input type="radio" name="payment_method_id" value="{p.id}" [if {_first}="1"]checked[/if]>
                <span class="bz-radio__body">
                  <span class="bz-radio__title">{p.title}</span>
                  [if {p.description}]<span class="bz-radio__desc">{p.description}</span>[/if]
                </span>
              </label>
            [/foreach]
          </div>
        [else]
          <p class="bz-muted">Способы оплаты не настроены администратором.</p>
        [/if]

        <h2 style="margin-top:24px">Промокод</h2>
        <div class="bz-promo">
          <div class="bz-promo__row">
            <input type="text" name="promo_code" placeholder="Введите код" autocomplete="off" style="text-transform:uppercase" data-promo-input>
            <button type="button" class="bz-btn-secondary" data-promo-apply>Применить</button>
          </div>
          <div class="bz-promo__status" data-promo-status hidden></div>
        </div>

        <h2 style="margin-top:24px">Комментарий</h2>
        <textarea name="comment" rows="2" placeholder="Комментарий к заказу"></textarea>

        <button type="submit" class="bz-btn-primary">{icon name="check" size="14"} Подтвердить заказ</button>
      </div>
    </form>

    <aside class="bz-cart-summary">
      <h3>В заказе</h3>
      <div data-checkout-summary>
        <p class="bz-muted">Загрузка…</p>
      </div>
    </aside>
  </div>
</div>

{include file="_partials/foot.tpl"}
