title: Woocommerce - How to check product type in plugin
body: <p>I'm pretty new to wordpress/woocommerce and just started playing with creating a custom plugin.</p>
  
  <p>So far I have I have added my custom woocommerce settings via the api.</p>
  
  <p>I've run into a problem where I want to add a custom field on a single product in the product data tab.</p>
  
  <p>I managed to display it using the following code:</p>
  
   
  
  <pre class="lang-php prettyprint-override"><code>add_action( 'woocommerce_product_options_general_product_data', array( $this, 'cuzd_general_fields' ) );
  add_action( 'woocommerce_process_product_meta', array( $this, 'cuzd_general_fields_save') );
  </code></pre>
  
  <p>However now I need to check if the product type is simple or variation.
  I tried the following:</p>
  
  
  
  <pre class="lang-php prettyprint-override"><code>$product = new WC_Product( get_the_ID() );
          if( $product-&gt;is_type( 'simple' ) ) {
            //
  }
  </code></pre>
  
  <p>However I get an error:</p>
  
  <pre class="lang-php prettyprint-override"><code> Fatal error: Class 'WC_Product' not found in ....
  </code></pre>
  
  <p>I have a good feeling I'm trying to initiate the Product class before its been called.
  I most likely have the whole format of the class plugin wrong.
  Any reading material with good instruction / best practice would be appreciated.</p>
  
  <p>Otherwise if the above is a simple fix please let me know.</p>