WooCommerce Variable Product notice Issue - please choose product options
<p>I'm  building an e-commerce site. I'm having some trouble with WooCommerce <strong>Variable Product</strong>.</p>

<p>The "Add to Cart" button works fine with simple products, but does not work with variable products. It gives a <code>"Please choose product options…"</code> notice.</p>

<p>I looked everywhere and tried several suggestions online, none of them work. So I looked into WooCommerce source file: <strong><code>class-wc-form-handler.php</code></strong>.</p>

<p>In the function <strong><code>add_to_cart_handler_variable</code></strong>:</p>

<pre><code>function add_to_cart_handler_variable( $product_id ) {
    $adding_to_cart     = wc_get_product( $product_id );
    $variation_id       = empty( $_REQUEST['variation_id'] ) ? '' : absint( $_REQUEST['variation_id'] );
    $quantity           = empty( $_REQUEST['quantity'] ) ? 1 : wc_stock_amount( $_REQUEST['quantity'] );
    $missing_attributes = array();
    $variations         = array();
    $attributes         = $adding_to_cart-&gt;get_attributes();
    $variation          = wc_get_product( $variation_id );
...
if ( $missing_attributes ) {
        wc_add_notice( sprintf( _n( '%s is a required field', '%s are required fields', sizeof( $missing_attributes ), 'woocommerce' ), wc_format_list_of_items( $missing_attributes ) ), 'error' );
    } elseif ( empty( $variation_id ) ) {
        wc_add_notice( __( 'Please choose product options&amp;hellip;', 'woocommerce' ), 'error' );
    } else {
        // Add to cart validation
        $passed_validation  = apply_filters( 'woocommerce_add_to_cart_validation', true, $product_id, $quantity, $variation_id, $variations );

        if ( $passed_validation &amp;&amp; WC()-&gt;cart-&gt;add_to_cart( $product_id, $quantity, $variation_id, $variations ) !== false ) {
            wc_add_to_cart_message( $product_id );
            return true;
        }
    }
    return false;
}
</code></pre>

<p>The error is caught in the elseif clause. <br>
So I tried to echo out <code>$variation_id</code>, <code>$variations</code>, and <code>$variation</code>. None of them has anything in it because when I echo <code>$variation_id</code>: it doesn't output anything.</p>

<p>Any suggestions?</p>