<p>You can use the <a href="https://craftcommerce.com/docs/craft-commerce-variants" rel="nofollow noreferrer">recently documented</a> template variable:</p>

<pre><code>craft.commerce.variants.id(yourVariantId).first()
</code></pre>

<p>If you want to get a variant's product from the variant ID, you can use:</p>

<pre><code>craft.commerce.products.hasVariant({id: yourVariantId}).first()
</code></pre>

<p><a href="https://craftcommerce.com/docs/craft-commerce-products#hasvariant" rel="nofollow noreferrer">https://craftcommerce.com/docs/craft-commerce-products#hasvariant</a></p>

CC BY-SA 3.0
2017-04-05T22:25:30.140Z
2017-04-06T00:02:51.420Z
2017-04-06T00:02:51.420Z
Jamie Pittock
<p>When looking up a specific product by ID, you'd do something like this:</p>

<pre><code>{% set product = craft.commerce.products.id(productId).first() %}
</code></pre>

<p>If you instead have a <strong>variant ID</strong> and want to find a specific <strong>variant</strong>, <em>what is the Variant equivalent of that code?</em></p>

<plugin-craftcommerce>
Look up a specific Variant, using the variant's ID?
# Look up a specific Variant, using the variant's ID?

(Asked by: username_0 on 2017-04-05)

When looking up a specific product by ID, you'd do something like this:
{% set product = craft.commerce.products.id(productId).first() %}

If you instead have a variant ID and want to find a specific variant, what is the Variant equivalent of that code?

**Tags:** plugin-craftcommerce

---

## 1 answers

### Answer by username_1 on 2017-04-05. Score: 3 | Accepted answer

You can use the recently documented template variable:
craft.commerce.variants.id(yourVariantId).first()

If you want to get a variant's product from the variant ID, you can use:
craft.commerce.products.hasVariant({id: yourVariantId}).first()

https://craftcommerce.com/docs/craft-commerce-products#hasvariant


---

