Alejandro Troncoso
2020-03-25T12:54:04Z

label_filters_result_not_in_stock.liquid

|
| {% capture selected_values %}
| {% for filter in filters %}
| {% for value in filter.values %}
| {% if value.selected %}
| {{value.name }}
| {% endif %}
| {% endfor %}
| {% endfor %}
| {% endcapture %}
|
| {% assign selected_values = selected_values | split: ' ' %}
| {% assign selected_values_count = selected_values.size %}
|
|
|
| {% for product in paged.products %}
| {% for variant in product.variants %}
| {% capture variant_values %}
| {% for value in variant.values %}
| {{value.name}}
| {%endfor%}
| {%endcapture%}
|
| {% assign variant_values = variant_values | split: ' ' %}
| {% assign filters_and_variant_values = variant_values | concat: selected_values %}
| {% assign filters_and_variant_values_uniq = variant_values | concat: selected_values | uniq %}
| {% assign dif_uniq = filters_and_variant_values.size | minus: filters_and_variant_values_uniq.size %}
| {% assign variant_is_selected = false %}
| {% if dif_uniq == selected_values_count %}
| {% assign variant_is_selected = true %}
| {% endif %}
|
| {% if variant_is_selected and variant.stock > 0 %}
| {% assign non_zero_stock = variant.stock %}
| {%endif%}
| {%endfor%}
|
|
|
|
|
|
|
| {% if non_zero_stock > 0 %}
| Selected variant has stock
| {%else%}
| Selected variant does not have stock
| {%endif%}
|