<p><code>product.variants|length</code> will in fact give you the exact number of variants the product has. If it is giving you an unexpected response, you’re probably just not looking at the right product in the first place. Try outputting the following to create a URL to the product’s edit page in the Control Panel:</p>

<pre><code>&lt;a href="{{ product.getCpEditUrl() }}"&gt;{{ product.title }}&lt;/a&gt;
</code></pre>

<p>Then click on that link from your browser to see the actual product you’re dealing with.</p>

CC BY-SA 3.0
2015-12-14T14:43:34.710Z
It goes to the correct product so i don't think that's the issue.
Christopher Healey
CC BY-SA 3.0
2015-12-14T14:53:53.923Z
Well it's magically working now. I'll create another question for the portion of my question you deleted because that's still not working.
Christopher Healey
CC BY-SA 3.0
2015-12-14T14:38:52.190Z
2015-12-14T14:38:52.190Z
Brandon Kelly
<p>I'm trying to test if a product has multiple variants AND/OR test for specific product variants. </p>

<pre><code>{% if product.variants|length &gt; 1 %}
</code></pre>

<p>That does not seem to work, even if it is a non-variant product. I understand that even for products without variants there is a 'default' variant, but shouldn't this return false if its a product type without variants given it should have only 1?</p>

<conditional><plugin-craftcommerce>
Test for specific or multiple product variants
# Test for specific or multiple product variants

(Asked by: username_0 on 2015-12-14)

I'm trying to test if a product has multiple variants AND/OR test for specific product variants. 
{% if product.variants|length > 1 %}

That does not seem to work, even if it is a non-variant product. I understand that even for products without variants there is a 'default' variant, but shouldn't this return false if its a product type without variants given it should have only 1?

**Tags:** conditional, plugin-craftcommerce

---

## 1 answers

### Answer by username_1 on 2015-12-14. Score: 1 | Accepted answer

product.variants|length will in fact give you the exact number of variants the product has. If it is giving you an unexpected response, you’re probably just not looking at the right product in the first place. Try outputting the following to create a URL to the product’s edit page in the Control Panel:
{{ product.title }}

Then click on that link from your browser to see the actual product you’re dealing with.

> **Comments:**
> **username_0**: It goes to the correct product so i don't think that's the issue.  
> **username_0**: Well it's magically working now. I'll create another question for the portion of my question you deleted because that's still not working.  

---

