Custom Theme | Excluding a Column | Customer Statement - Unpaid Invoice

The code fragment was missing the first for loop.

This one should work:

{% assign removedCols = 1 %}
{% for column in table.columns %}
    {% if column.label == 'Order number' %}
        {% assign j = forloop.index0%}
        {% assign removedCols = removedCols | plus: 1 %}
        {% continue %}
    {% endif%}
    <td class="text-{{ column.align }} border-start{% if forloop.last == true %} border-top border-end{% endif %}" style="font-weight: solid;font-size: 8px ;padding: 0.5px; border-bottom-width: 1px; border-top-width: 1px{% if column.nowrap %}; width: 0px{% endif %}">{{ column.label | replace: "Order number", "Fee Name" }}</td>
    {% if column.label == 'Overdue' %}{% assign i = forloop.index0 %}{% endif %}
{% endfor %}

{% for row in table.rows %}
    {% unless row.cells[i].text == '-' %}
        <tr>
            {% for cell in row.cells %}
                {% if forloop.index0 == j %}{% continue %}{% endif %}
                <td class="text-{{ table.columns[forloop.index0].align }} border-start{% if forloop.last == true %} border-end{% endif %}" style="font-size: 8px; padding: 0.1px; {% if table.columns[forloop.index0] %}; width: 0px{% endif %}">   {{ cell.text | newline_to_br }}</td>
            {% endfor %}
        </tr>
    {% endunless %}       
{% endfor %}

Mind that you’d have to also make some adjustments to the number of columns, because they might change. Also, they may not change in some cases so it’d better be dynamic. That’s why I added the variable removedCols that you can use to adjust the columns

2 Likes