<p><code>product.variants</code> just returns an actual array of the variants, not an ElementCriteriaModel. So you can’t chain on additional params like <code>order</code>.</p>

<p>To get variants using custom parameters, you can do this:</p>

<pre><code>{% set variants = craft.commerce.variants({
    product: product,
    order: 'price asc'
}) %}

{% for purchasable in variants %}
    // ...
{% endfor %}
</code></pre>

CC BY-SA 3.0
2016-06-22T17:31:48.030Z
2016-06-22T17:31:48.030Z
Brandon Kelly
<p>In Craft Commerce is it possible to order each product variant in the template, I would like to order by price ascending, I've tried the below but nothing is returned?</p>

<pre><code>{% for purchasable in product.variants.order('price asc') %}
</code></pre>

<p>Below works but displays in order they were added:</p>

<pre><code>{% for purchasable in product.variants %}
</code></pre>

<plugin-craftcommerce>
How can I order each product variant in my templates?
# How can I order each product variant in my templates?

(Asked by: username_0 on 2016-06-16)

In Craft Commerce is it possible to order each product variant in the template, I would like to order by price ascending, I've tried the below but nothing is returned?
{% for purchasable in product.variants.order('price asc') %}

Below works but displays in order they were added:
{% for purchasable in product.variants %}

**Tags:** plugin-craftcommerce


---

## 1 answers

### Answer by username_1 on 2016-06-22. Score: 3 | Accepted answer

product.variants just returns an actual array of the variants, not an ElementCriteriaModel. So you can’t chain on additional params like order.
To get variants using custom parameters, you can do this:
{% set variants = craft.commerce.variants({
    product: product,
    order: 'price asc'
}) %}

{% for purchasable in variants %}
    // ...
{% endfor %}


---

