title: WooCommerce (WordPress) - Last product in loop
body: <p><a href="http://tp4x4.v2webdesign.co.uk/products/" rel="nofollow noreferrer">http://tp4x4.v2webdesign.co.uk/products/</a></p>
  
  <p>I'm wondering if it possible to find out when the category/product loop is the last.</p>
  
  <p>I'm in the process of building a custom template and to organise the products I am using the foundation grid system.</p>
  
  <p>This is in files: content-product-cat.php &amp; content-product.php</p>
  
  <pre><code>  &lt;?php if ($woocommerce_loop['loop']&amp;1){ ?&gt;
      &lt;div class="row product-grid-row"&gt; &lt;?php }?&gt;
        &lt;div class="product-category product large-6 small-12 columns"&gt;
  
      content stuff is here
        &lt;/div&gt;
  
    &lt;?php if ($woocommerce_loop['loop']&amp;2) { ?&gt;&lt;/div&gt;&lt;?php } ?&gt;
  </code></pre>
  
  <p>This code opens the .product-grid-row  for each odd number and closes it for each even number, creating 2 products per row.</p>
  
  <p>The problem is when the last product is an odd number or there is an odd number if products/categories.</p>
  
  <p>If there is a way to determine the number of categories/products in that loop I can simply use that variable:</p>
  
  <pre><code>if ($lastinloop) echo "&lt;/div&gt;";
  </code></pre>
  
  <p>I have also tried using the loop_shop_columns feature of WooCommerce but this poses the same problem if the last product is not at the end of a row.</p>