'How to include Variables from one template in another

I have an Online shop (It's Shopware 6 [Symfony, twig]). in Product detail Page i Show the variation. and when they out of stock i make them grey:

enter image description here

but the Problem is in Product-Listing page, I can't grey out the out of stock products in Quick view because my Variable won't load:

enter image description here

I was Wondering if i can include somehow the Variables like:

    {% sw_include '@Storefront/storefront/page/product-detail/configurator.html.twig' with {notinhere : page.unavailable} %}

UPDATE: This code is in my Configurator.html.twig :

    {% set notinhere = page.unavailable %}
    <div class="product-detail-configurator-option {% if option.id in page.unavailable %}grau-labels{% endif %}">
        {% block page_product_detail_configurator_option_radio %}
            <input type="radio" name="{{ group.id }}" value="{{ option.id }}" class="product-detail-configurator-option-input{% if isCombinableCls %} {{ isCombinableCls }}{% endif %}" title="{{ optionIdentifier }}" id="{{ optionIdentifier }}" {% if isActive %} checked="checked" {% endif %}>
        </div>
    {% endblock %}

And then this file included in my buy-widget.html.twig

{% if page.product.parentId and page.configuratorSettings|length > 0 %}
    <div class="product-detail-configurator-container">
        {% sw_include '@Storefront/storefront/page/product-detail/configurator.html.twig' %}
    </div>
{% endif %}

And Product-detail page using this (buy-widget.html.twig) and the it works just fine in Product-detail page.

my quick-view twig includes this:

    {% sw_include '@Storefront/storefront/page/product-detail/buy-widget.html.twig' %}

so, i tried to add with notinhere : page.unavailable on both sw_include and it still not working. What is the problem here?!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source