{% load basket_tags %}
{% load i18n %}
{% load purchase_info_tags %}

{% purchase_info_for_product request product as session %}

{% if session.availability.is_available_to_buy %}
    {% basket_form request product as basket_form %}
    <form id="add_to_basket_form" action="{% url 'basket:add' %}" method="post" class="form-stacked add-to-basket">
        {% csrf_token %}
        {% include "partials/form_fields.html" with form=basket_form %}
        <button type="submit" class="btn btn-large btn-primary btn-block" value="{% trans "Add to basket" %}">{% trans "Add to basket" %}</button>
    </form>
    {% include "catalogue/partials/add_to_wishlist.html" %}
{% else %}
    {% if has_active_alert %}
        <p>{% trans "You have an active stock alert for this product." %}</p>
    {% else %}
        <form id="alert_form" method="post" action="{% url 'customer:alert-create' pk=product.id %}" class="add-to-basket">
            {% csrf_token %}
            <p>{% trans "You can get an email alert when this product is back in stock." %}</p>
            {% include "partials/form_fields.html" with form=alert_form %}
            <button type="submit" class="btn btn-large btn-info btn-block">{% trans "Notify me" %}</button>
        </form>
    {% endif %}
    {% include "catalogue/partials/add_to_wishlist.html" %}
{% endif %}
