Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Add new checkout templates

Patryk Zawadzkidcea1a8d8759
diff --git a/saleor/checkout/templates/checkout/address_form.html b/saleor/checkout/templates/checkout/address_form.html
new file mode 100644
index 0000000000..5bce8cf5e8
--- /dev/null
+++ b/saleor/checkout/templates/checkout/address_form.html
@@ -0,0 +1,62 @@
+{% load i18n %}
+{% load static from staticfiles %}
+{% load as_vertical_form from bootstrap %}
+
+<div class="row">
+ <div class="btn-group-vertical col-sm-12" data-toggle="buttons">
+ {% if step.shipping_address %}
+ <label for="{{ addresses_form.address.html_name }}_copy" class="btn btn-default{% if copy_shipping_address %} active{% endif %}">
+ <input type="radio"
+ name="{{ addresses_form.address.html_name }}"
+ value="copy"
+ id="{{ addresses_form.address.html_name }}_copy"
+ {% if copy_shipping_address %}checked{% endif %}>
+ {% trans "Use shipping address for billing" %}
+ </label>
+ {% endif %}
+
+ {% if addresses %}
+ {% for address in addresses %}
+ <label for="{{ addresses_form.address.html_name }}_{{ address.id }}" class="btn btn-default{% if address.is_selected %} active{% endif %}">
+ <input type="radio"
+ name="{{ addresses_form.address.html_name }}"
+ value="{{ address.id }}"
+ id="{{ addresses_form.address.html_name }}_{{ address.id }}"
+ {% if address.is_selected %}checked{% endif %}>
+ {% include "userprofile/snippets/address-details.html" with address=address %}
+ </label>
+ {% endfor %}
+ {% endif %}
+
+ {% if step.shipping_address or addresses %}
+ <label for="{{ addresses_form.address.html_name }}_new" class="btn btn-default{% if new_address %} active{% endif %}">
+ <input type="radio"
+ name="{{ addresses_form.address.html_name }}"
+ value=""
+ id="{{ addresses_form.address.html_name }}_new"
+ {% if new_address %}checked{% endif %}>
+ {% trans "Enter a new address" %}
+ </label>
+ {% endif %}
+ </div>
+</div>
+<div class="conditional-visibility" data-controller="input[name={{ addresses_form.address.html_name }}]" data-value="">
+ <br>
+ {% if display_email_form %}
+ {{ step.forms.email|as_vertical_form }}
+ {% endif %}
+
+ <div class="i18n-address" data-address-url="{% static 'js/address.json' %}" data-lang="{{ LANGUAGE_CODE }}" data-prefix="{{ step.forms.new_address.prefix }}">
+ {{ step.forms.new_address.first_name|as_vertical_form }}
+ {{ step.forms.new_address.last_name|as_vertical_form }}
+ {{ step.forms.new_address.company_name|as_vertical_form }}
+ {{ step.forms.new_address.street_address_1|as_vertical_form }}
+ {{ step.forms.new_address.street_address_2|as_vertical_form }}
+ {{ step.forms.new_address.city|as_vertical_form }}
+ {{ step.forms.new_address.city_area|as_vertical_form }}
+ {{ step.forms.new_address.postal_code|as_vertical_form }}
+ {{ step.forms.new_address.country|as_vertical_form }}
+ {{ step.forms.new_address.country_area|as_vertical_form }}
+ </div>
+ {{ step.forms.new_address.phone|as_vertical_form }}
+</div>
diff --git a/saleor/checkout/templates/checkout/details.html b/saleor/checkout/templates/checkout/details.html
index 5a65440406..5f2853af8a 100644
--- a/saleor/checkout/templates/checkout/details.html
+++ b/saleor/checkout/templates/checkout/details.html
@@ -1,6 +1,9 @@
{% extends "base.html" %}
{% load i18n %}
+{% load gross from prices_i18n %}
+{% load tax from prices_i18n %}
+
{% block title %}{% trans "Checkout" %} — {{ block.super }}{% endblock %}
@@ -19,25 +22,98 @@
{% block footer %}
{% endblock %}
+{% if not user.is_authenticated %}
+ <p class="alert alert-info">
+ {% trans "Already have an account?" %}
+ <a href="{% url "registration:login" %}?next={% url "checkout:details" step="shipping-address" %}">
+ {% trans "Log in" %}
+ </a>
+ </p>
+{% endif %}
+
{% block content %}
-<ul class="nav nav-pills nav-justified nav-wizard">
- {% for stepitem in checkout %}
- <li class="{% if stepitem == step %}active{% endif %}">
- {% if not forloop.first %}
- <div class="nav-wedge"></div>
- {% endif %}
- <a href="{{ stepitem.get_absolute_url }}">{% if stepitem %}<i class="fa fa-check-circle"></i> {% endif %}{{ stepitem.title }}</a>
- {% if not forloop.last %}
- <div class="nav-arrow"></div>
- {% endif %}
- </li>
- {% endfor %}
-</ul>
-
-<hr>
-
-{% block step_info %}{% endblock %}
-
-{% block forms %}{% endblock %}
+ {% if not user.is_authenticated %}
+ <p class="alert alert-info">
+ {% trans "Already have an account?" %}
+ <a href="{% url "registration:login" %}?next={% url "checkout:details" step="shipping-address" %}">
+ {% trans "Log in" %}
+ </a>
+ </p>
+ {% endif %}
+ {% block step_info %}{% endblock %}
+
+ <div class="row">
+ <div class="col-sm-8">
+ <ul class="nav nav-pills nav-justified nav-wizard">
+ {% for stepitem in checkout %}
+ <li{% if stepitem == step %} class="active"{% endif %}>
+ {% if not forloop.first %}
+ <div class="nav-wedge"></div>
+ {% endif %}
+ <a{% if stepitem.is_step_available %} href="{{ stepitem.get_absolute_url }}"{% endif %}>
+ {{ stepitem.title }}
+ </a>
+ {% if not forloop.last %}
+ <div class="nav-arrow"></div>
+ {% endif %}
+ </li>
+ {% endfor %}
+ </ul>
+
+ {% block forms %}{% endblock %}
+ </div>
+
+ <div class="col-sm-4">
+ {% for delivery, delivery_cost, total_with_delivery in checkout.get_deliveries %}
+ <div class="panel panel-default">
+ <div class="panel-heading">
+ {% blocktrans with number=forloop.counter %}Shipment #{{ number }}{% endblocktrans %}
+ </div>
+ <table class="table">
+ <thead>
+ <tr>
+ <th class="col-sm-6">{% trans "Item" %}</th>
+ <th class="col-sm-3 text-right">{% trans "Price" %}</th>
+ <th class="col-sm-3 text-right">{% trans "Subtotal" %}</th>
+ </tr>
+ </thead>
+ <tfoot>
+ <tr>
+ <th colspan="2">{% trans "Total" %}</th>
+ <th class="text-right">{% gross total_with_delivery %}</th>
+ </tr>
+ </tfoot>
+ <tbody>
+ {% for item in delivery %}
+ <tr>
+ <td>{{ item.product }}{% if item.quantity != 1 %} <em>×{{ item.quantity }}</em>{% endif %}</td>
+ <td class="text-right">{% gross item.get_price_per_item %}</td>
+ <td class="text-right">{% gross item.get_total %}</td>
+ </tr>
+ {% endfor %}
+ {% if delivery_cost.gross %}
+ <tr>
+ <td>
+ {% trans "Shipping" %}
+ </td>
+ <td class="text-right">{% gross delivery_cost %}</td>
+ <td class="text-right">{% gross delivery_cost %}</td>
+ </tr>
+ {% endif %}
+ </tbody>
+ </table>
+ </div>
+ {% endfor %}
+ {% with total=checkout.get_total %}
+ <div class="alert alert-success">
+ {% trans "Your total will be" %}:
+ <strong>{% gross total %}</strong>
+ {% if total.tax %}
+ ({% blocktrans with tax=total.tax|floatformat:2 currency=total.currency %}includes {{ tax }} <span class="currency">{{ currency }}</span> tax{% endblocktrans %})
+ {% endif %}
+ </div>
+ {% endwith %}
+ </div>
+ </div>
{% endblock content %}
diff --git a/saleor/checkout/templates/checkout/shipping_address.html b/saleor/checkout/templates/checkout/shipping_address.html
new file mode 100644
index 0000000000..c443a76f0e
--- /dev/null
+++ b/saleor/checkout/templates/checkout/shipping_address.html
@@ -0,0 +1,21 @@
+{% extends "checkout/details.html" %}
+{% load i18n %}
+
+
+{% block forms %}
+ <form method="post">
+ {% csrf_token %}
+ <h4>{% trans "Shipping address" %}</h4>
+ {% if user.is_authenticated %}
+ {% include "checkout/address_form.html" with addresses_form=step.forms.addresses_form %}
+ {% else %}
+ {% include "checkout/address_form.html" with addresses_form=step.forms.addresses_form display_email_form=True %}
+ {% endif %}
+ <br>
+ <p class="text-right">
+ <button type="submit" class="btn btn-primary btn-lg">
+ {% trans "Continue to shipping method" %}
+ </button>
+ </p>
+ </form>
+{% endblock %}
diff --git a/saleor/checkout/templates/checkout/shipping_method.html b/saleor/checkout/templates/checkout/shipping_method.html
new file mode 100644
index 0000000000..5819c3210f
--- /dev/null
+++ b/saleor/checkout/templates/checkout/shipping_method.html
@@ -0,0 +1,36 @@
+{% extends "checkout/details.html" %}
+{% load i18n %}
+{% load gross from prices_i18n %}
+
+
+{% block forms %}
+ <form method="post">
+ {% csrf_token %}
+ <h4>{% trans "Shipping method" %}</h4>
+ <div class="row">
+ <div class="btn-group-vertical col-sm-12" data-toggle="buttons">
+ {% with delivery_form=step.forms.delivery %}
+ {% for method in available_deliveries %}
+ {% with method_name=method.method.name %}
+ <label for="{{ delivery_form.method.html_name }}_{{ method_name }}" class="btn btn-default{% if method_name == selected_method_name %} active{% endif %}">
+ <strong>{{ method.method }}</strong><br>
+ <span class="badge">{% gross method.cost %}</span>
+ <input type="radio"
+ name="{{ delivery_form.method.html_name }}"
+ value="{{ method_name }}"
+ id="{{ delivery_form.method.html_name }}_{{ method_name }}"
+ {% if method_name == selected_method_name %}checked{% endif %}>
+ </label>
+ {% endwith %}
+ {% endfor %}
+ {% endwith %}
+ </div>
+ </div>
+ <br>
+ <p class="text-right">
+ <button type="submit" class="btn btn-primary btn-lg">
+ {% trans "Continue to payment" %}
+ </button>
+ </p>
+ </form>
+{% endblock %}
diff --git a/saleor/checkout/templates/checkout/summary.html b/saleor/checkout/templates/checkout/summary.html
index 5e08e72cb5..b430920aea 100644
--- a/saleor/checkout/templates/checkout/summary.html
+++ b/saleor/checkout/templates/checkout/summary.html
@@ -1,108 +1,19 @@
{% extends "checkout/details.html" %}
-{% load gross from prices_i18n %}
-{% load tax from prices_i18n %}
+{% load as_vertical_form from bootstrap %}
{% load i18n %}
{% load staticfiles %}
-{% block forms %}
- <div class="row">
- <div class="col-sm-6">
- <div class="panel panel-default">
- <div class="panel-heading">
- {% trans "Billing address" %}
- </div>
- <div class="panel-body">
- {% if checkout.billing_address %}
- <address>{% include "userprofile/snippets/address-details.html" with address=checkout.billing_address %}</address>
- {% else %}
- <p class="text-danger">{% trans "No address given yet." %}</p>
- {% endif %}
- <p><a href="{{ checkout.billing.get_absolute_url }}">{% trans "Edit billing details" %}</a></p>
- </div>
- </div>
- </div>
- {% if checkout.is_shipping_required %}
- <div class="col-sm-6">
- <div class="panel panel-default">
- <div class="panel-heading">
- {% trans "Shipping address" %}
- </div>
- <div class="panel-body">
- {% if checkout.shipping_address %}
- <address>{% include "userprofile/snippets/address-details.html" with address=checkout.shipping_address %}</address>
- {% else %}
- <p class="text-danger">{% trans "No address given yet." %}</p>
- {% endif %}
- <p><a href="{{ checkout.shipping.get_absolute_url }}">{% trans "Edit shipping details" %}</a></p>
- </div>
- </div>
- </div>
- {% endif %}
- </div>
-
- {% for delivery, delivery_cost, total_with_delivery in checkout.get_deliveries %}
- <div class="panel panel-default">
- <div class="panel-heading">
- {% blocktrans with number=forloop.counter %}Shipment #{{ number }}{% endblocktrans %}
- </div>
- <table class="table">
- <thead>
- <tr>
- <th class="col-sm-6">{% trans "Item" %}</th>
- <th class="col-sm-3 text-right">{% trans "Price" %}</th>
- <th class="col-sm-3 text-right">{% trans "Subtotal" %}</th>
- </tr>
- </thead>
- <tfoot>
- <tr>
- <th colspan="2">{% trans "Total" %}</th>
- <th class="text-right">{% gross total_with_delivery %}</th>
- </tr>
- </tfoot>
- <tbody>
- {% for item in delivery %}
- <tr>
- <td>{{ item.product }}{% if item.quantity != 1 %} <em>×{{ item.quantity }}</em>{% endif %}</td>
- <td class="text-right">{% gross item.get_price_per_item %}</td>
- <td class="text-right">{% gross item.get_total %}</td>
- </tr>
- {% endfor %}
- {% if delivery_cost.gross %}
- <tr>
- <td>
- {% trans "Shipping" %}
- </td>
- <td class="text-right">{% gross delivery_cost %}</td>
- <td class="text-right">{% gross delivery_cost %}</td>
- </tr>
- {% endif %}
- </tbody>
- </table>
- </div>
- {% endfor %}
- {% with total=checkout.get_total %}
- <div class="alert alert-success">
- {% trans "Your total will be" %}:
- <strong>{% gross total %}</strong>
- {% if total.tax %}
- ({% blocktrans with tax=total.tax|floatformat:2 currency=total.currency %}includes {{ tax }} <span class="currency">{{ currency }}</span> tax{% endblocktrans %})
- {% endif %}
- </div>
- {% endwith %}
-
- {% if all_steps_valid %}
- <form method="post">
- {% csrf_token %}
- <p>
- <button type="submit" class="btn btn-primary btn-lg pull-right">
- {% trans "Place order" %}
- </button>
- </p>
- </form>
- {% else %}
- <div class="alert alert-danger">
- <p>{% trans "Before continuing please make sure that you've provided all of the information required." %}</p>
- </div>
- {% endif %}
+{% block forms %}
+ <form method="post">
+ {% csrf_token %}
+ <h4>{% trans "Billing address" %}</h4>
+ {% include "checkout/address_form.html" with addresses_form=step.forms.addresses_form %}
+ <br>
+ <p class="text-right">
+ <button type="submit" class="btn btn-primary btn-lg">
+ {% trans "Place order" %}
+ </button>
+ </p>
+ </form>
{% endblock forms %}