title: change title of variable woocommerce product based on attribute value selection
body: <p>I want to change the Woocommerce variable product title when someone selects the varient. I want to add the selected variant to title.
  I have used this <a href="https://stackoverflow.com/questions/47462265/change-woocommerce-variable-product-title-based-on-variation">Change WooCommerce variable product title based on variation</a> code It's working perfectly for attributes that are added from product-&gt;attributes .But i want that to work for custom product attributes which we add when adding product.</p>
  <p>I tried the code provided in above link for that but it's not working for custom product attributes.It returns a null value.
  colorr is the name of attribue i added using custom product attributes
  Here is my code.Any help will be highly appriciated</p>
  <pre><code>add_filter( 'wp_footer','custom_product_title_script' );
  function custom_product_title_script(){
      global $post;
  
      // Only single product pages
      if( ! is_product() ) return;
  
      // get an instance of the WC_Product Object
      $product = wc_get_product($post-&gt;ID);
  
      // Only for variable products
      if( ! $product-&gt;is_type( 'variable' ) ) return;
  
      // Here set your specific product attributes in this array (coma separated):
      $attributes = array('colorr');
  
      // The 1st loop for variations IDs
      foreach($product-&gt;get_visible_children( ) as $variation_id ) {
  
          // The 2nd loop for attribute(s)/value
          foreach($product-&gt;get_available_variation( $variation_id )['attributes'] as $key =&gt; $value_id ){
              $taxonomy = str_replace( 'attribute_', '', $key ); // Get the taxonomy of the product attribute
  
              // Just for defined attributes
              if( in_array( $taxonomy, $attributes) ){
                  // Set and structure data in an array( variation ID =&gt; product attribute =&gt; term name )
                  $data[ $variation_id ][$taxonomy] = get_term_by( 'slug', $value_id, $taxonomy )-&gt;name;
              }
          }
      }
  
      ?&gt;
          &lt;script type=&quot;text/javascript&quot;&gt;
              (function($){
                  // variables initialization
                  var variationsData = &lt;?php echo json_encode($data); ?&gt;,
                      productTitle = $('.product_title').text(),
                      color = 'colorr';
                  console.log(variationsData);
  
                  // function that get the selected variation and change title
                  function update_the_title( productTitle, variationsData, color ){
                      $.each( variationsData, function( index, value ){
                          if( index == $('input.variation_id').val() ){
                              $('.product_title').text(productTitle+' - '+value[color]);
                              console.log('TITLE UPDATED');
                              return false;
                          } else {
                              $('.product_title').text(productTitle);
                          }
                      });
                  }
  
                  // Once all loaded
                  setTimeout(function(){
                      update_the_title( productTitle, variationsData, color );
                  }, 300);
  
                  // On live event: select fields
                  $('select').blur( function(){
                      update_the_title( productTitle, variationsData, color );
                  });
              })(jQuery);
          &lt;/script&gt;
      &lt;?php
  }
  
  </code></pre>