Okay. I've figured it out but it left me with the question. After some page refreshes It's got stack back at empty output again.
Bad:
{% cache %}
{% for item in orders %}
{# Following variable was the problem #}
{% set cart = item.cart %}
{# Loop in cart's table fields: title and quantity #}
{% for row in cart %}
{% set data = data|merge([{ title: row.title, quantity: row.quantity }]) %}
{% endfor %}
{% endfor %}
{% endcache %}
On second page load it outputs nothing. So I simply call for a check like this.
{% for item in data %}
{# for example #}{{ item.title }}
{% endfor %}
Good:
This is my current state of the code design. It's a bit extended to the original post. But a problem may be in data merging into an array.
{# Prep array #}
{% set data = [] %}
{% cache %}
{% for item in orders %}
{# Loop in cart's table fields: title and quantity #}
{% for row in item.cart %}
{% set data = data|merge([{ title: row.title, quantity: row.quantity }]) %}
{% endfor %}
{% endfor %}
{% endcache %}
{% set someProduct = 'someProduct' %}
{% set someOrderQuantity = 0 %}
{# Count order's quantity #}
{% for item in data %}
{% if someProduct = item.title %}
{% set someOrderQuantity = someOrderQuantity + item.quantity %}
{% endif %}
{% endfor %}
Setting variable I don't know why was setting variable in entries loop for another loop causing that empty output?
I properly don't know how cart
to reuse in orders
loop and wrap in cache
tags wasn't good idea because it outputted nothing. So I had to take cart
variable out. It worked out butcache
tags works?