title: Custom Woocommerce product weight calculation from dimensions
body: <p>When adding products to my woocommerce store I set weight (in kg) and dimensions (in cm). If [(Height x Length x Width) / 5000] is higher than actual weight then I want this to be used to calculate shipping.</p>
  
  <p>I thought I could use a filter to manipulate $weight but with no success. Here is my code:</p>
  
  <pre><code>function woocommerce_product_get_weight_from_dimensions( $weight ) {
      global $product;
      $product = wc_get_product( id );
      $prlength = $product-&gt;get_length();
      $prwidth = $product-&gt;get_width();
      $prheight = $product-&gt;get_height();
      $dimensions = $prlength * $prwidth * $prheight;
      $dweight = $dimensions / 5000;
      if ($dweight &gt; $weight) {
          return $dweight;
      }
      return $weight;
  }
  add_filter('woocommerce_product_get_weight', 'woocommerce_product_get_weight_from_dimensions');
  </code></pre>
  
  <p>What am i doing wrong?</p>