{% load url from future %}
{% load basket_tags %}
{% load i18n %}

{% if product.is_available_to_buy %}
    {% basket_form request product as basket_form %}
    {% if basket_form.purchase_permitted %}
        <form action="{% url 'basket:add' %}" method="post" class="form-stacked">
            {% csrf_token %}
            {% include "partials/form_fields.html" with form=basket_form %}
            <div class="form-actions">
                <button type="submit" class="btn btn-large btn-primary btn-full" value="{% trans "Add to basket" %}">{% trans "Add to basket" %}</button>
            </div>
        </form>
    {% else %}
        {{ basket_form.reason }}
    {% endif %}
{% 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' product.id %}">
            {% 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-full">{% trans "Notify me" %}</button>
        </form>
    {% endif %}
{% endif %}

{% load url from future %}
{% load basket_tags %}
{% load i18n %}
{% load stockrecord_tags %}

{% session_strategy request product as session %}

{% if session.availability.is_available_to_buy %}
    {% basket_form request product as basket_form %}
    {% if basket_form.purchase_permitted %}
        <form action="{% url 'basket:add' %}" method="post" class="form-stacked">
            {% csrf_token %}
            {% include "partials/form_fields.html" with form=basket_form %}
            <div class="form-actions">
                <button type="submit" class="btn btn-large btn-primary btn-full" value="{% trans "Add to basket" %}">{% trans "Add to basket" %}</button>
            </div>
        </form>
    {% else %}
        {{ basket_form.reason }}
    {% endif %}
{% 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' product.id %}">
            {% 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-full">{% trans "Notify me" %}</button>
        </form>
    {% endif %}
{% endif %}

Remove deprecated use of product.is_available_to_buy
Remove deprecated use of product.is_available_to_buy
