{% sw_extends '@Storefront/storefront/component/product/card/action.html.twig' %}
{% block component_product_box_action_inner %}
{% set baseConfig = context.extensions.maxiaListingVariants %}
{% set variantsConfig = product.extensions.maxiaListingVariants %}
{% set isAvailable = (not product.isCloseout or (product.availableStock >= product.minPurchase)) and product.calculatedMaxPurchase > 0 %}
{% set isVariantProduct = product.parentId or product.childCount %}
{% set isParentProduct = product.childCount > 0 %}
{% if variantsConfig.quickBuyActive %}
{% set switched = app.request.query.get('switched') %}
{% set showPopupButton = (not isAvailable or isParentProduct or variantsConfig.isPartialConfiguration)
and not variantsConfig.isExpanded
and variantsConfig.hasAvailableVariant
and switched is null %}
{% set includeQuickBuyActions = ((isAvailable and not isParentProduct) or showPopupButton)
and (isVariantProduct or baseConfig.activateForMainProducts) %}
{% block component_product_box_action_maxia_quickbuy_actions_include %}
{% if includeQuickBuyActions %}
{% block component_product_box_action_maxia_quickbuy_actions %}
{# Quantity and cart button #}
{% block component_product_box_action_maxia_quickbuy_actions_inner %}
<div class="product-action maxia-quickbuy-actions{% if baseConfig.showAdditionalDetailLink %} detail-button-active{% endif %}">
{% sw_include '@Storefront/storefront/plugins/maxia_listing_variants/listing-actions.html.twig' %}
</div>
{% endblock %}
{% if baseConfig.showAdditionalDetailLink %}
{# Show detail button below cart button #}
{% block component_product_box_action_maxia_detail_button_extra %}
{% sw_include '@Storefront/storefront/plugins/maxia_listing_variants/listing-detail-button.html.twig' %}
{% endblock %}
{% endif %}
{% endblock %}
{% else %}
{% if isVariantProduct or baseConfig.activateForMainProducts %}
{# Show detail button if product is unavailable #}
{% block component_product_box_action_maxia_detail_button %}
{% sw_include '@Storefront/storefront/plugins/maxia_listing_variants/listing-detail-button.html.twig' %}
{% endblock %}
{% else %}
{# Default buy actions #}
{{ block('component_product_box_action_inner') }}
{% endif %}
{% endif %}
{% endblock %}
{% else %}
{{ parent() }}
{% endif %}
{% block component_product_box_action_maxia_variants_config %}
{% if product.extensions.maxiaListingVariants is defined %}
{% sw_include '@Storefront/storefront/plugins/maxia_listing_variants/config.html.twig' %}
{% endif %}
{% endblock %}
{% block component_product_box_action_meta %}
{{ parent() }}
{% endblock %}
{% endblock %}