title: Set a custom product field programmatically using a method in Woocommerce
body: <p>I'm trying to add a custom field in the general section of a product and initialize it with a frontend form.</p>
  <p>I had no problem in adding it, but I'm little lost on how to set it.</p>
  <p><strong>TO ADD AND SAVE THE CUSTOM FIELD:</strong></p>
  <pre><code>// The code for displaying WooCommerce Product Custom Fields
  add_action('woocommerce_product_options_general_product_data', 'woocommerce_product_custom_fields');
  // Following code Saves  WooCommerce Product Custom Fields
  add_action('woocommerce_process_product_meta', 'woocommerce_product_custom_fields_save');
  
  
  function woocommerce_product_custom_fields()
  {
      global $woocommerce, $post;
      echo '&lt;div class=&quot; product_custom_field &quot;&gt;';
  
      //Custom Product Text Field
      woocommerce_wp_text_input(
          array(
              'id'          =&gt; 'tipologiaAppunto',
              'label'       =&gt; __('Tipologia appunto:', 'woocommerce'),
              'placeholder' =&gt; '',
              'desc_tip'    =&gt; 'true'
          )
      );
      echo '&lt;/div&gt;';
  }
  
  
  function woocommerce_product_custom_fields_save($post_id)
  {
      // Custom Product Text Field
      $woocommerce_custom_product_text_field = $_POST['tipologiaAppunto'];
      if (!empty($woocommerce_custom_product_text_field))
          update_post_meta($post_id, 'tipologiaAppunto', esc_attr($woocommerce_custom_product_text_field));
  }
  </code></pre>
  <p>To set it I've tried to extend the <code>WC_PRODUCT CLASS</code></p>
  <p><strong>EXTENSION OF THE WC_PRODUCT CLASS:</strong></p>
  <pre><code>add_action('init', 'register_myclass');
  function register_myclass()
  {
      class WC_ProductExtended extends WC_Product
      {
          function __construct() {
              parent::__construct();
              if (!array_key_exists(&quot;tipologiaAppunto&quot;, $this-&gt;data)) {
                  $this-&gt;data[&quot;tipologiaAppunto&quot;] = &quot;&quot;;
              }
          }
  
          /**
           * Set product tipologiaAppunto.
           *
           * @since 3.0.0
           * @param string $tipologiaAppunto Product tipologiaAppunto.
           */
          public function set_tipologiaAppunto($tipologiaAppunto)
          {
              $this-&gt;set_prop( 'tipologiaAppunto', $tipologiaAppunto );
          }
      }
  }
  </code></pre>
  <p>And now by calling the setter I was hoping to initialize the product custom field, but nothing happened.</p>
  <pre><code>$product-&gt;set_regular_price($_POST['price']); 
  $productExtendend = new WC_ProductExtended();
  $productExtendend-&gt;set_tipologiaAppunto(&quot;Hey&quot;);
  $productExtendend-&gt;save(); 
  
  </code></pre>
  <p>I don't know If this is the right I way, I found a lot of tutorial on how to add the custom field but   so little on how to initialize it from the frontend, I've tried by mimic the behaviour of the existing fields but with no luck.</p>