{% extends "base.html" %}
{% load i18n %}

{% block extra_head %}
<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>
{% endblock %}

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

{% block breadcrumb_menu %}
<ul>
    <li><a href="{% url home %}">{% trans "Home" %}</a> &gt;</li>
    <li>{% trans "Checkout" %}</li>
</ul><br />
{% endblock %}

{% block main %}
<div>{% trans "Order complete" %}</div>
{% endblock %}

