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

{% purchase_info_for_product request product as session %}


<form action="{% url 'basket:add' pk=product.pk %}" method="post" class="add_to_basket_form_compact">
    {% csrf_token %}
    <div class="inline_add_to_basket_button">
    {% if product.is_parent or product.has_options %}
    <a class="btn {% if not session.availability.is_available_to_buy %}btn-danger{% elif session.availability.is_backorder %}btn-warning text-white{% else %}btn-primary{% endif %}" href="{{ product.get_absolute_url }}">
        <i class="fa fa-plus"></i> {% trans "View" %}
    </a>
    {% elif session.availability.is_available_to_buy %}
    {% if session.availability.is_backorder %}
        <div class="availability-message backorder">
            {{session.availability.message}}
        </div>
    {% endif %}
    <label>
        <input type="hidden" name="quantity" value="1" id="id_quantity" aria-labelledby="Add to basket">
    </label>
    <button type="submit" class="btn-add-to-basket btn {% if session.availability.is_backorder %}btn-warning text-white{% elif not session.availability.is_available_to_buy %}{% else %}btn-primary{% endif %}" data-loading-text="{% trans 'Adding...' %}">
        <i class="fa fa-shopping-cart-solid"></i> {% trans "Add" %}
    </button>

    {% else %}
    <span class="btn btn-danger disabled">
        {{session.availability.message}}
    </span>
    {% endif %}
    </div>
</form>