Answers.Body: <p>You're always using variants. Just that if you have no 'other' variants commerce hides that stuff away. But your product has a defaultVariant behind the scenes.</p>
  
  <p>Adding…</p>
  
  <pre><code>.hasVariant({ hasStock: true })
  </code></pre>
  
  <p>…to your query <em>should</em> (I think) return your products that have ([hidden] variants in) stock.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-04-07T21:30:15.737Z
Answers.LastActivityDate: 2020-04-07T21:30:15.737Z
Answers.UserDisplayName: billythekid
Body: <p>In Craft Commerce, how can I show only products that are in stock when <strong>not using variants</strong>?</p>
  
  <p>For example, this query, but only show products with a stock with 1 or more:</p>
  
  <pre><code>{% set productQuery = craft.products()
          .relatedTo(block.relation)
          .availableForPurchase()
          .order('postDate desc')
          .limit(4) %}
  
      {% set products = productQuery.all() %}
  
      {% for product in products %}
        {% include "_components/product-blurb.html" %}
      {% endfor %}
  </code></pre>
  
Tags: <plugin-craftcommerce>
Title: Show only products in stock - one variant only
ThreadText: # Show only products in stock - one variant only
  
  (Asked by: username_0 on 2020-04-07)
  
  In Craft Commerce, how can I show only products that are in stock when **not using variants**?
  
  For example, this query, but only show products with a stock with 1 or more:
  
  ```
  {% set productQuery = craft.products()
          .relatedTo(block.relation)
          .availableForPurchase()
          .order('postDate desc')
          .limit(4) %}
  
      {% set products = productQuery.all() %}
  
      {% for product in products %}
        {% include "_components/product-blurb.html" %}
      {% endfor %}
  
  ```
  
  **Tags:** plugin-craftcommerce
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-04-07. Score: 2 | Accepted answer
  
  You're always using variants. Just that if you have no 'other' variants commerce hides that stuff away. But your product has a defaultVariant behind the scenes.
  
  Adding…
  
  ```
  .hasVariant({ hasStock: true })
  
  ```
  
  …to your query *should* (I think) return your products that have ([hidden] variants in) stock.
  
  
  ---
  
  