title: WooCommerce - How to get shipping class of cart items in calculate_shipping function?
body: <p>I have created a WooCommerce plugin that enables free shipping for subscribers. It seems to have broken following a recent WooCommerce upgrade.</p>
  
  <p>Specifically, the problem seems that the shipping class of the cart items may not be being retrieved correctly.</p>
  
  <p>Here is my calculate_shipping code - can anyone advise what is wrong?</p>
  
  <pre><code>/**
   * Add free shipping option for customers in base country with an active subscription,
   * but only if the cart doesn't contain an item with the 'heavy-item-shipping-class'.
   *
   * @access public
   * @param mixed $package
   * @return void
   */
  public function calculate_shipping($package) {
  
      global $woocommerce;
  
      // Check country and subscription status
      if (is_user_in_base_country() &amp;&amp; does_user_have_active_subscription()) {
  
          // This flag will be set to TRUE if cart contains heavy items
          $disable_free_shipping = FALSE;
  
          // Get cart items
          $cart_items = $package['contents'];
  
          // Check all cart items
          foreach ($cart_items as $cart_item) {
  
              // Get shipping class
              $shipping_class = $cart_item['data']-&gt;shipping_class; // *** IS THIS THE RIGHT WAY TO GET THE SHIPPING CLASS ??? ***
  
              // If heavy item, set flag so free shipping option is not made available
              if ($shipping_class === 'heavy-item-shipping-class') {
  
                  // Set flag
                  $disable_free_shipping = TRUE;
  
                  // Enough
                  break;
  
              }
  
          }
  
          // If appropriate, add the free shipping option
          if ($disable_free_shipping === FALSE) {
  
              // Create the new rate
              $rate = array(
                  'id' =&gt; $this-&gt;id,
                  'label' =&gt; "Free Shipping",
                  'cost' =&gt; '0',
                  'taxes' =&gt; '',
                  'calc_tax' =&gt; 'per_order'
              );
  
              // Register the rate
              $this-&gt;add_rate($rate);
  
          }
          else {
  
              // Doesn't qualify for free shipping, so do nothing
  
          }
  
      }
  
  }
  </code></pre>
  
  <p><strong>UPDATE</strong>
  I've looked at the <code>%package</code> array and noticed that it now contains the shipping class under <code>[shipping_class:protected]</code>. (Previously, this must have been <code>[shipping_class]</code>.) Is it possible to extract this data? If not, what is the correct way of doing it?</p>