Get only enabled variants of a product
If you already have the product

PHP

$product = Product::find()-&gt;one();
$variants = ArrayHelper::filterByValue($product-&gt;variants, 'enabled', 1);


Twig

{% set product = craft.products.one() %}
{% set variants = product.variants|filterByValue('enabled', "1") %}


If you don't have the product

Twig

{% set variants = craft
    .commerce
    .variants
    .productId(x)
    .all() 
%}


PHP

$variants = Variant::find()
    -&gt;productId(x)
    -&gt;all();