{% extends "shop/base.html" %}
{% load i18n future %}

{% block meta_title %}{% trans "Order Complete" %}{% endblock %}

{% block extra_head %}
{{ block.super }}
{% if settings.GOOGLE_ANALYTICS_ID %}
<script>

var decimal = function(amount) {
    if (amount.toString().indexOf('.') == -1) {
        amount += '.00';
    }
    return String(amount);
};

var _gaq = [['_trackPageview'], ['_addTrans',
    // order ID - required
    '{{ order.id }}',
    // affiliation or store name
    '',
    // total - required
    decimal({{ order.item_total }}{% if order.discount_total %} - {{ order.discount_total }}{% endif %}),
    // tax
    decimal({% if order.tax_total %}{{ order.tax_total }}{% else %}0{% endif %}),
    // shipping
    decimal({{ order.shipping_total }}),
    // city
    '{{ order.billing_detail_city|escapejs }}',
    // state or province
    '{{ order.billing_detail_state|escapejs }}',
    // country
    '{{ order.billing_detail_country|escapejs }}'
]];

{% for item in items %}
_gaq.push(['_addItem',
	// order ID - required
	'{{ order.id }}',
	// SKU/code - required
	'{{ item.sku }}',
	// product name
	'{{ item.name|escapejs }}',
	// category or variation
	'{{ item.description|escapejs }}',
	// unit price - required
	decimal({{ item.unit_price }}),
	// quantity - required
	'{{ item.quantity }}'
]);
{% endfor %}

// submits transaction to the Analytics servers
_gaq.push(['_trackTrans']);

</script>
{% endif %}
{% endblock %}

{% block title %}{% trans "Order Complete" %}{% endblock %}

{% block breadcrumb_menu %}
{% for step in steps %}
<li>
    {{ step.title }}
    <span class="divider">/</span>
</li>
{% endfor %}
<li><strong>{% trans "Complete" %}</strong></li>
{% endblock %}


{% block main %}
<p>{% trans "Thank you for shopping with us, your order is complete." %}</p>
<p>{% trans "We've sent you a receipt via email." %}</p>
<p>{% trans "You can also view your invoice using one of the links below." %}</p>
<br>
<p>
    <a class="btn btn-large btn-primary" href="{% url "shop_invoice" order.id %}?format=pdf">{% trans "Download PDF invoice" %}</a>
    <a class="btn btn-large" target="_blank" href="{% url "shop_invoice" order.id %}">{% trans "View invoice in your browser" %}</a>
</p>
{% endblock %}

