Commerce: How can I check order history to see if a product type has been purchased? I am building a plugin that grants access to a "hidden" (for lack of better words) entry. if a user has purchased a specific product type.

For example, I don't care which piece of clothing the user purchases, just as long as it was of type clothing. 

How can I check the users order history to see if they have purchased a qualifying product?

Thank you for any suggestions!
First you'll need to grab the user's orders. Then you can check the product type through the purchasable. 

Something like this:

{% set orders = craft.commerce.orders.user(currentUser).find() %}

{% if orders|length %}
    {% for order in orders %}
        {% for lineItem in order.lineItems %}
            {{ lineItem.purchasable.product.typeId }} {# 1 #}
        {% endfor %}
    {% endfor %}
{% endif %}


You can take that a step further by doing something like this:

{% set orders = craft.commerce.orders.user(currentUser).find() %}
{% set product = false %} {# set the condition to false by default. #}

{% if orders|length %}
    {% for order in orders %}
        {% for lineItem in order.lineItems if lineItem.purchasable.product.typeId == 1 %}
            {% set product = true %}
        {% endfor %}
    {% endfor %}
{% else %}
    {# No orders found. #}
{% endif %}

...

{% if product %}
    {# User has purchased product type at some point in time. #}
{% else %}
    {# User has never purchased product type. #}
{% endif %}