Viewing 5 replies - 1 through 5 (of 5 total)
  • Mahfuzur Rahman

    (@mahfuzurwp)

    Hi @vicsansos,

    Thanks for reaching out and for sharing the screenshots.

    I had a look, and I can confirm the issue when some variations are out of stock, the product is marked as “Out of stock” on the archive page, even though other variations are still available.

    This is expected WooCommerce behavior when none of the in-stock variations are set as the default variation. The archive page doesn’t evaluate all variations—it looks for a default one to determine stock status.

    To fix this:

    • Edit the product in your dashboard.
    • Scroll down to the Variations tab.
    • Set one of the in-stock variations as the Default form values.

    Once done, clear WooCommerce Transients and Regenerate Product Lookup Tables:

    • Go to WooCommerce > Status > Tools.
    • Click on “Clear transients” to remove outdated cached data.
    • Use the “Regenerate product lookup tables” tool to refresh product visibility and stock status data

      Please try these out and let us know what happens.

      Thread Starter Víctor Sánchez Sosa

      (@vicsansos)

      Hi @mahfuzurwp

      But this product has no default option set up, wich variation Woocommerce evaluate?

      Thank you

      Jonayed (woo-hc)

      (@jonayedhosen)

      Hi @vicsansos ,

      Thanks for getting back to us — and great observation!

      But this product has no default option set up, wich variation Woocommerce evaluate?

      By default, WooCommerce looks at the stock status of all variations for a variable product. As long as at least one variation is in stock, the product should show as “In stock” on the archive or shop page, even if no default variation is set. That way, shoppers know there’s still something available to purchase.

      That said, the way this shows up can sometimes be influenced by your theme or certain plugins. For example, some themes override how product data is handled on the front end, and plugins that manage variations, swatches, or inventory might also change how WooCommerce decides what to display. Even a bit of custom code can sometimes affect this behavior.

      If things aren’t displaying as expected, a good next step would be to run a quick conflict test. That just means:

      • Temporarily switching to a default theme like Storefront
      • Deactivating all plugins except WooCommerce
      • Removing any custom code (if added)

      Here’s a quick guide to walk you through the process: https://woocommerce.com/document/how-to-test-for-conflicts/

      Once you’ve done that, take another look at your shop page and let me know what you see.

      Thread Starter Víctor Sánchez Sosa

      (@vicsansos)

      Hi Jonayed.

      I found a solution that works for me.

      I have adapted this snippet with Woodmart hooks and it works.

      This is the original snippet:

      add_action( 'woocommerce_after_shop_loop_item_title', 'mostrar_estado_stock_en_listados', 20 );

      function mostrar_estado_stock_en_listados() {
      global $product;

      if ( ! is_a( $product, 'WC_Product' ) ) return;

      $has_stock = false;

      if ( $product->is_type( 'variable' ) ) {
      // Para productos variables: revisar variaciones
      $variations = $product->get_children();
      foreach ( $variations as $variation_id ) {
      $variation = wc_get_product( $variation_id );
      if ( $variation && $variation->is_in_stock() ) {
      $has_stock = true;
      break;
      }
      }
      } else {
      // Para productos simples y otros tipos
      $has_stock = $product->is_in_stock();
      }

      echo '<p class="custom-stock-status" style="color:' . ( $has_stock ? 'green' : 'red' ) . ';">' .
      ( $has_stock ? 'Hay stock' : 'Próximamente/bajo pedido' ) .
      '</p>';
      }

      This is adpated one:

      add_action( 'woocommerce_after_shop_loop_item_title', 'mostrar_estado_stock_en_listados', 5 );

      function mostrar_estado_stock_en_listados() {
      global $product;

      if ( ! is_a( $product, 'WC_Product' ) ) return;

      $has_stock = false;

      if ( $product->is_type( 'variable' ) ) {
      foreach ( $product->get_children() as $variation_id ) {
      $variation = wc_get_product( $variation_id );
      if ( $variation && $variation->is_in_stock() ) {
      $has_stock = true;
      break;
      }
      }
      } else {
      $has_stock = $product->is_in_stock();
      }

      echo '<p class="custom-stock-status ' . ( $has_stock ? 'in-stock' : 'out-of-stock' ) . '">' .
      esc_html( $has_stock ? '✔ En stock' : 'Próximamente/bajo pedido' ) .
      '</p>';

      }

      And it works for now.

      Zee

      (@doublezed2)

      Hello vicsansos,

      I’m glad to hear that you’ve resolved the issue. Thank you for sharing the solution here. It’s much appreciated and may help others as well.

      If you feel that WooCommerce has been beneficial to your business, we would be truly grateful if you could take a few moments to leave a review.

      Your feedback not only supports our continuous improvement but also helps others make informed decisions about using WooCommerce.

      Have a great day!

    Viewing 5 replies - 1 through 5 (of 5 total)

    The topic ‘Out of stock issue in product archive’ is closed to new replies.