title: Select variation option with jQuery woocommerce
body: <p>I need to change the variation of a woocommerce product in jQuery.</p>
  
  <p>i have this function <code>changeColorVar(selectbox,color)</code></p>
  
  <p>this function should change the color of the current selectbox and update the woocommerce variable price, but it doesn't update the price, here is the function body</p>
  
  <pre><code> function changeColVar(selectbox,color){
  
      $form = $(".variations_form"); //GETTING THE FORM
  
      $form.trigger( 'woocommerce_variation_select_focusin' ); //that we've focused in 
      $(selectbox).find( 'option' ).each(function() {
        $(this)
          .prop('selected', $(this).val() == color); //Setting the selectbox value
      });
      $(selectbox).trigger('change'); //Trying to call woocommerce "check_variations" to update price
  
  
  }      
  </code></pre>
  
  <p>aprec any help!</p>
  
  <p>I'm editing the content-product page in woocommerce, 
  I'm showing the variations and add to cart button using this</p>
  
  <pre><code> if( $product-&gt;is_type( 'variable' ) ) {
                                do_action('woocommerce_variable_add_to_cart');
                               }
                               else {
                                   do_action('woocommerce_add_to_cart');
                               }
  </code></pre>
  
  <p>I'm also displaying a button in the single product page that does changeColVar function.
  when I click on this button i want to change one attributes ("#pa_color") to "Red" value automatically, and updating the price.</p>
  
  <p>I found last this answer but I haven't solved my problem.
  <a href="https://stackoverflow.com/questions/24279555/woocommerce-trigger-event-after-change-of-variation">WooCommerce: trigger event after change of variation</a></p>