title: updating woocommerce shipping values at runtime
body: <p>I am fairly new to php and woocommerce. I am working on a ecommerce website which uses wordpress and woocommerce. The company uses and API to calculate the shipping costs based on area and dimensions of the items in the cart as well as item quantity. I have managed to parse all needed values to the API and i do get a response. I created a custom shipping plugin for the 3 testing rates provided.
  in my script i create sessions that holds the total of each shipping method inside it like this:</p>
  
  <pre><code>    $_SESSION['overnight']= $quoteResponse-&gt;results[0]-&gt;rates[2]-&gt;total;
  </code></pre>
  
  <p>and then in my custom shipping plugin i start the session and set the cost equal   to      the value inside the session:</p>
  
  <pre><code>    &lt;?php
      session_start();
  
      * Check if WooCommerce is active
      */
      if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins',     get_option( 'active_plugins' ) ) ) ) {
  
      function WC_Overnight_Express_init() {
      if ( ! class_exists( 'WC_Overnight_Express' ) ) {
      class WC_Overnight_Express extends WC_Shipping_Method {
      /**
      * Constructor for your shipping class
      *
      * @access public
      * @return void
      */
     public function __construct() {
     $this-&gt;id = 'overnight express'; // Id for your shipping method. Should be uunique.
     $this-&gt;method_title = __( 'Overnight Express' ); // Title shown in admin
     $this-&gt;method_description = __( 'Overnight Express Shipping method' ); 
  
     $this-&gt;enabled = "yes"; // This can be added as an setting but for this example its forced enabled
     $this-&gt;title = "Overnight Express"; // This can be added as an setting but for this example its forced.
  
     $this-&gt;init();
     }
  
     /**
     * Init your settings
     *
     * @access public
     * @return void
     */
     function init() {
     // Load the settings API
     $this-&gt;init_form_fields(); // This is part of the settings API. Override the method to add your own settings
     $this-&gt;init_settings(); // This is part of the settings API. Loads settings you previously init.
  
  
     // Save settings in admin if you have any defined
     add_action( 'woocommerce_update_options_shipping_' . $this-&gt;id, array( $this,      'process_admin_options' ) );
     }
  
     /**
     * calculate_shipping function.
     *
     * @access public
     * @param mixed $package
     * @return void
     */
     public function calculate_shipping() {
     $rate = array(
     'id' =&gt; $this-&gt;id,
     'label' =&gt; $this-&gt;title,
     'cost' =&gt;$_SESSION['overnight'],
     'calc_tax' =&gt; 'per_item'
     );
  
     // Register the rate
     $this-&gt;add_rate( $rate );
     }
     } 
     }
     }
  
     add_action( 'woocommerce_shipping_init', 'WC_Overnight_Express_init' );
  
     function add_overnight_method( $methods ) {
     $methods[] = 'WC_Overnight_Express'; 
     return $methods;
     }
  
     add_filter( 'woocommerce_shipping_methods', 'add_overnight_method' );
     }
  
     ?&gt;
  </code></pre>
  
  <p>My problem is my after the quotes return from the API they dont update shipping totals they display "free" and only udpate if I open my cart and go back to the checkout page. What I wanna do is update them at runtime when the totals are returned from the API. This is my first post on stackoverlow And any help will be greatly appreciated. Thanks</p>