title: Display a form when the selected variation is out of stock in WooCommerce
body: <p>In WooCommerce with <a href="https://wordpress.org/plugins/contact-form-7/" rel="nofollow noreferrer">Contact Form 7 plugin</a>, I have added a form to my out of stock simple products, on single product pages, using the following code:</p>
  <pre><code>add_action( 'woocommerce_single_product_summary', 'add_contact_form', 30, 2 );
  function add_contact_form() {
      global $product;
  
      if( ! $product-&gt;is_in_stock( ) &amp;&amp; ! $product-&gt;is_type('variable') ) {
         echo do_shortcode('[contact-form-7 id=&quot;14880&quot; title=&quot;Fiyat Sorunuz&quot;]');
      }
  }
  </code></pre>
  <p>This &quot;out of stock&quot; form works just well for simple products:</p>
  <p><a href="https://i.stack.imgur.com/ZJN29.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZJN29.png" alt="out of stock form works" /></a></p>
  <hr />
  <p><strong>But doesn't work on &quot;out of stock&quot; product variations</strong> for variable products:</p>
  <p><a href="https://i.stack.imgur.com/FgJsk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FgJsk.png" alt="only out of stock. How can I add a variant form?" /></a></p>
  <p>How can I display this form for selected product variation that are out of stock?</p>
  <p>Any help is appreciated.</p>