title: Class function for custom shipping method on Woocommerce checkout page
body: <p>I use custom plugin for Woocommerce shipping method. The plugin run a new class which extends WC_Shipping_MEthod, but the problem is the 'cost' price is calculated in other function outsite the class.</p>
  
  <p>So in the current class I have:</p>
  
  <pre><code>        public function calculate_shipping( $package=array() ) {
  
           /*   $this-&gt;add_rate( array(
                      'id'    =&gt; $this-&gt;id . $this-&gt;instance_id,
                      'label' =&gt; $this-&gt;title,
                      'cost'  =&gt; 0,
              ) ); */
  
              $rate = array(
                  'id' =&gt; $this-&gt;id,
                  'label' =&gt; $this-&gt;title,
                  'cost' =&gt; 0,
                  'taxes' =&gt;false,
                  //'calc_tax' =&gt; 'per_item'
              );
  
               // Register the rate
              $this-&gt;add_rate( $rate );
  
          }
  </code></pre>
  
  <p>Outside the class, in another file, I have a function, which calculates the cost for shipping:</p>
  
  <pre><code>//add shipping cost to checkout total
  add_action('woocommerce_cart_calculate_fees', 'woo_add_cart_fee');
  
  function woo_add_cart_fee() {
  
      global $woocommerce;
      $woocommerce-&gt;shipping;
      $wc_econt = new WC_Econt_Shipping_Method;
  
       if ( is_checkout() &amp;&amp; (bool)$wc_econt-&gt;inc_shipping_cost == TRUE ) {
          if(!isset($_SESSION)){ 
              session_start(); 
          } 
          //write_log('session econt customer shipping cost:'.$_SESSION['econt_shipping_cost']);
          $extracost = (isset($_SESSION['econt_shipping_cost']) ? $_SESSION['econt_shipping_cost'] : 0 );
          if ($extracost != '0') {
              WC()-&gt;cart-&gt;add_fee(__('Econt Express Shipping Method','woocommerce-econt'), $extracost);       
          }
      }
  }
  </code></pre>
  
  <p>If just change 0 to $extracode in the class function it doesn't update the shipping cost on checkout page:</p>
  
  <p>public function calculate_shipping( $package=array() ) {</p>
  
  <pre><code>     /*   $this-&gt;add_rate( array(
                  'id'    =&gt; $this-&gt;id . $this-&gt;instance_id,
                  'label' =&gt; $this-&gt;title,
                  'cost'  =&gt; $extracost,
          ) ); */
  
          $rate = array(
              'id' =&gt; $this-&gt;id,
              'label' =&gt; $this-&gt;title,
              'cost' =&gt; $extracost,
              'taxes' =&gt;false,
              //'calc_tax' =&gt; 'per_item'
          );
  
           // Register the rate
          $this-&gt;add_rate( $rate );
  
      }
  </code></pre>
  
  <p>I guess the class run before the woo_add_cart_fee function, and that's why it cannot get the value of $extracost variable.</p>
  
  <p>How to resolve this?</p>