Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Move discount form to snippet
Michał Ociepka0d7fe1bbd415
diff --git a/saleor/checkout/templates/checkout/details.html b/saleor/checkout/templates/checkout/details.htmlindex 14d9008b08..a149ad9d08 100644--- a/saleor/checkout/templates/checkout/details.html+++ b/saleor/checkout/templates/checkout/details.html@@ -2,7 +2,6 @@{% load i18n %}{% load gross net tax from prices_i18n %}-{% load bootstrap_form bootstrap_button from bootstrap3 %}{% block title %}{% trans "Checkout" %} — {{ block.super }}{% endblock %}@@ -62,13 +61,17 @@</div><div class="col-sm-4">- <table class="table">+ <table class="table table-condensed"><tbody>{% for delivery, delivery_cost, total_with_delivery in checkout.deliveries %}{% for item in delivery %}<tr>- <td>{{ item.product }}{% if item.quantity != 1 %} <span class="badge">×{{ item.quantity }}</span>{% endif %}</td>- <td class="text-right">{% net item.get_total %}</td>+ <td class="noborder">+ {{ item.product.product }}{% if item.quantity != 1 %} <span class="badge">×{{ item.quantity }}</span>{% endif %}+ <br>+ <small>{{ item.product }}</small>+ </td>+ <td class="noborder text-right">{% net item.get_total %}</td></tr>{% endfor %}{% endfor %}@@ -81,11 +84,14 @@{% net checkout.get_subtotal %}</td></tr>++ {% include 'checkout/snippets/voucher-form.html' with discount=checkout.discount form=voucher_form %}+<tr>- <td>+ <td class="noborder">{% trans "Shipping" %}</td>- <td class="text-right">+ <td class="noborder text-right">{% if checkout.shipping_method %}{% net checkout.get_total_shipping %}{% else %}@@ -94,43 +100,13 @@</td></tr>- {% if voucher_form %}- <tr>- {% if voucher %}- {% with discount=checkout.discount %}- <td>- <form action="{% url "checkout:remove-voucher" %}?next={{ request.get_full_path }}"- method="post" class="form-inline">- {% csrf_token %}- <span class="text-success">{{ discount.name }}</span>- <button type="submit" class="btn btn-link" aria-label="{% trans "Remove" %}"><span class="glyphicon glyphicon-remove-circle"></span></button>- </form>- </td>- <td class="text-right">- - {% net discount.amount %}- </td>- {% endwith %}- {% else %}- <td colspan="2">- <form action="{% url "checkout:add-voucher" %}?next={{ request.get_full_path }}"- method="post" class="form-inline text-center">- {% csrf_token %}- {% bootstrap_form voucher_form layout="inline" %}- {% bootstrap_button _("Apply") button_type="submit" button_class="btn-primary" %}- </div>- </form>- </td>- {% endif %}- </tr>- {% endif %}-{% with total=checkout.get_total %}{% if total.tax or True %}<tr>- <td>+ <td class="noborder">{% trans "Taxes" %}</td>- <td class="text-right">+ <td class="noborder text-right">{% tax total %}</td></tr>diff --git a/saleor/checkout/templates/checkout/snippets/voucher-form.html b/saleor/checkout/templates/checkout/snippets/voucher-form.htmlnew file mode 100644index 0000000000..329413ae4d--- /dev/null+++ b/saleor/checkout/templates/checkout/snippets/voucher-form.html@@ -0,0 +1,33 @@+{% load bootstrap_field bootstrap_button bootstrap_icon from bootstrap3 %}+{% load trans from i18n %}+{% load gross net tax from prices_i18n %}++{% if form %}+ <tr>+ {% if discount %}+ <td class="noborder">+ <form action="{% url "checkout:remove-voucher" %}?next={{ request.path }}"+ method="post"+ class="form-inline">+ {% csrf_token %}+ <span class="text-success">{{ discount.name }}</span>+ <button type="submit"+ class="btn btn-link btn-xs"+ aria-label="{% trans "Remove" %}">+ {% bootstrap_icon "remove" %}+ </button>+ </form>+ </td>+ <td class="noborder text-right">+ - {% net discount.amount %}+ </td>+ {% else %}+ <form action="{% url "checkout:add-voucher" %}?next={{ request.path }}"+ method="post" class="form-inline">+ {% csrf_token %}+ <td class="noborder form-group">{% bootstrap_field form.voucher show_label=False form_group_class="" %}</td>+ <td class="noborder text-right">{% bootstrap_button _("Apply") button_type="submit" button_class="btn-default" %}</td>+ </form>+ {% endif %}+ </tr>+{% endif %}diff --git a/saleor/static/scss/_app.scss b/saleor/static/scss/_app.scssindex 4f1b58f06c..1d00da06f9 100644--- a/saleor/static/scss/_app.scss+++ b/saleor/static/scss/_app.scss@@ -2,6 +2,10 @@ $icon-font-path: "../fonts/";@import "bootstrap-sass/assets/stylesheets/bootstrap";@import "font-awesome/scss/font-awesome";+.table > tbody > tr > td.noborder {+ border-top: 1px solid transparent;+}+.navbar {margin-bottom: $grid-gutter-width;}