{% sw_extends '@Storefront/storefront/component/buy-widget/buy-widget-price.html.twig' %}
{% block buy_widget_price_inner %}
    {% if product.calculatedPrices|length > 1 %}
        {% block buy_widget_price_block %}
           {{ parent() }}
        {% endblock %}
    {% else %}
        {% set price = product.calculatedPrice %}

        {% if product.calculatedPrices|length == 1 %}
            {% set price = product.calculatedPrices.first %}
        {% endif %}

        <meta itemprop="price"
              content="{{ price.unitPrice }}">

         {% block buy_widget_price_content %}
            {% set listPrice = price.listPrice %}
            {% set isListPrice = price.listPrice.percentage > 0 %}
            {% set isRegulationPrice = price.regulationPrice != null %}

            <p class="product-detail-price{% if isListPrice %} with-list-price{% endif %}{% if isRegulationPrice %} with-regulation-price{% endif %}">
                {{ price.unitPrice|currency }}
            </p>

            {% if isListPrice %}
                {% block buy_widget_was_price %}
                    <div class="list_cut_price">
                        {% block buy_widget_was_price_badge %}
                        {{ parent() }}
                        {% endblock %}

                        {% set afterListPriceSnippetExists = 'listing.afterListPrice'|trans|length > 0 %}
                        {% set beforeListPriceSnippetExists = 'listing.beforeListPrice'|trans|length > 0 %}

                        {% block buy_widget_was_price_wrapper %}
                            {{ parent() }}
                        {% endblock %}
                    </div>
                {% endblock %}
            {% endif %}
            {% if isRegulationPrice %}
                <span class="product-detail-list-price-wrapper">
                    <span class="regulation-price">
                    {{ 'general.listPricePreviously'|trans({'%price%': price.regulationPrice.price|currency }) }}
                    </span>
                </span>
            {% endif %}
            
        {% endblock %}

        {% if product.purchaseUnit %}
            {% block buy_widget_price_unit %}
                {% set productunitprice = theme_config('theme-product-detail-unitprice-show') %}
		        {% if productunitprice == "1" %}
                    {{ parent() }}
                {% endif %}
            {% endblock %}
        {% endif %}
    {% endif %}
{% endblock %}
