{% extends "product/product.html" %}
{% load i18n %}
{% load thumbnail %}
{% load satchmo_price %}
{% load satchmo_util %}
{% load satchmo_currency satchmo_category%}
{% load satchmo_discounts satchmo_tax %}
{% load app_plugins %}
{% load satchmo_thumbnail %}

{% block extra-head %}

{% include "shop/_jquery.html" %}
{% include "shop/_jquery_form.html" %}
<script type="text/javascript" src="{{media_url}}js/satchmo_product.js"></script>
{% blackbird_logging %}
<script type="text/javascript">{# Javascript which is generated uniquely for each page #}
satchmo.default_view_tax = {% if default_view_tax %}true{% else %}false{% endif %};

satchmo.variations = {{ details|as_json }};

satchmo.set_option_ids([{% for option_group in options %}{{ option_group.id }}{% if not forloop.last %},{% endif %}{% endfor %}]);

$(function() {
    satchmo.update_price();
    $('.priced').change(function() { satchmo.update_price() });
});

// generate thumbnails for all alternate images
satchmo.thumbnails = new Array();
{{ details|js_thumbnail_array:"width=280,height=280" }}
</script>
{% endblock %}

{% block productdetail %}
<h4>{{ product.translated_name }}</h4>
<p>{{ product.translated_description }}</p>
{% trans "Price" %}{% if default_view_tax %} {% trans '(incl. tax)' %}{% endif %}: <h3>{% spaceless %}
	{% if sale %}<strike style="display: block;" id="fullprice">{{ product|discount_price:""|currency }}</strike>{% endif %}
	<span id="price">{{ product|discount_price:sale|currency }}</span>
	{% endspaceless %}</h3>

<span id="product_images">
{% for pic in product.productimage_set.all %}
    {% thumbnail pic.picture 280x280 as image %}
    <img src="{{ image }}" width="{{ image.width }}" height="{{ image.height }}" />
{% endfor %}
</span>

{% with product.translated_attributes as atts %}{% if atts %}
<p class="productattributes">
{% for att in product.translated_attributes %}
{{ att.description }}: {{ att.value }}<br/>
{% endfor %}
</p>
{% endif %}{% endwith %}

{% if error_message %}<p><strong>{{ error_message }}</strong></p>{% endif %}
<form id="options" action="{% url satchmo_smart_add %}" method="post">{% csrf_token %}
{% if options %}
<p>{% trans "Please choose your options" %}:</p>
{% endif %}

{% for option_group in options %}
 {{ option_group.name }}
    <select name="{{ option_group.id }}" id="{{option_group.id}}" class="priced">
    {% for choice in option_group.items %}
     <option value="{{ choice.value }}" {% if choice.selected %}selected="selected"{% endif %}>{{ choice.translated_name }}
        {% if choice.price_change %}
            {% option_price choice %}
        {% endif %}
     </option>
    {% endfor %}
      </select>
{% endfor %}
{% trans "Quantity" %} <input type="text" size="2" name="quantity" id="quantity" value="1" class="priced" />
<input type="hidden" name="productname" id="productname" value="{{product.slug}}" />
<input id="addcart" type="submit" name="addcart" value="{% trans "Add to cart" %}" />
{% plugin_point "product_add_buttons" %}
{% plugin_point "product_form" %}
</form>
{% endblock %}
