title: move out of stock products at the end in WooCommerce
body: <p>I would like to show out of stock products at the end in woocommerce</p>
  
  <p>I have code it works but footer doesn't display then.</p>
  
  <p>can anyone help me?</p>
  
  <p>this is the code</p>
  
  <pre><code>&lt;?php
  
  /**
   * Order product collections by stock status, instock products first.
   */
  class iWC_Orderby_Stock_Status
  {
  
      public function __construct()
      {
          // Check if WooCommerce is active
          if (in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option('active_plugins')))) {
              add_filter('posts_clauses', array($this, 'order_by_stock_status'), 2000);
          }
      }
  
      public function order_by_stock_status($posts_clauses)
      {
          global $wpdb;
          // only change query on WooCommerce loops
          if (is_woocommerce() &amp;&amp; (is_shop() || is_product_category() || is_product_tag())) {
              $posts_clauses['join'] .= " INNER JOIN $wpdb-&gt;postmeta istockstatus ON ($wpdb-&gt;posts.ID = istockstatus.post_id) ";
              $posts_clauses['orderby'] = " istockstatus.meta_value ASC, " . $posts_clauses['orderby'];
              $posts_clauses['where'] = " AND istockstatus.meta_key = '_stock_status' AND istockstatus.meta_value &lt;&gt; '' " . $posts_clauses['where'];
          }
          return $posts_clauses;
      }
  }
  
  new iWC_Orderby_Stock_Status;
  
  ?&gt;
  </code></pre>