How to output taxCategory in Craft Commerce I'm trying to test for a taxCategory within Craft Commerce and finding it awkward to do so. I can't see much in the docs, but have managed to put this together:

{% if product.taxCategory | length %}
    {% for taxCategory in product.taxCategory %}
        {# loops through the taxCategory with the first string being the id, #}
        {# the second the name and the third string seems to be the slug #}
        {% if loop.index == 3 and taxCategory == "withVat" %}
            +VAT
        {% endif %}
    {% endfor %}
{% endif %}


But it doesn't seem very elegant. Any suggestions? The docs example probably needs updating, I think, because:

{% for taxCategory in craft.commerce.taxCategories %}
    {{ taxCategory.id }} - {{ taxCategory.name }}
{% endfor %}
{% endif %}


...outputs: "Impossible to access an attribute ("id") on a string variable"
You can simplify your first bit of code by using:

{{ product.taxCategory.name == 'withVat' ? '+VAT' }}

The reason you get the error with your second bit of code is because craft.commerce.taxCategories is only an array of Tax Category names. Only the models of each Tax Category would have properties such as .id and .name