title: How to retrieve cart_item_data with WooCommerce?
body: <p>During the <a href="http://docs.woothemes.com/wc-apidocs/source-class-WC_Cart.html#755-894"><code>add_to_cart</code></a> function, there is a filter to add "cart item data". The filter is <code>woocommerce_add_cart_item_data</code>. I expected to store my custom plugin data in this, so that the data is stored relative to the item and multiple products can be added with different data.</p>
  
  <p>This all seemed to work, but I am not able to retrieve the data. I can't figure it out. <strong>The data is there</strong>, I can see it in a serialized string, but I can't pull it out.</p>
  
  <pre><code>echo '&lt;pre&gt;';
  var_dump( WC() );
  
  foreach( WC()-&gt;cart-&gt;get_cart() as $cart_item ) {
    var_dump( $cart_item );
    var_dump( WC()-&gt;cart-&gt;get_item_data( $cart_item ) );
  }
  echo '&lt;/pre&gt;';
  </code></pre>
  
  <p>The first dump of <code>WC()</code> has a property: <code>session-&gt;_data-&gt;cart-&gt;(serialized data)</code>. The _data property is protected, though, but I can see my custom field inside the serialized data.</p>
  
  <p>The $cart_item is an array with <code>product_id</code> and some other data, but it does not include my custom data :(</p>
  
  <p>Finally, using the <a href="http://docs.woothemes.com/wc-apidocs/source-class-WC_Cart.html#_get_item_data"><code>get_item_data()</code></a> method I thought I had it all figured out. I passed in the cart item object, and... an empty string. Same if I pass the key, rather than the cart item itself.</p>
  
  <p><strong>How am I supposed to access the cart item data?</strong></p>
  
  <hr>
  
  <p>Here is the "Add cart item data" function, which works (or at least seems to work):</p>
  
  <pre><code>function save_class_menu_selection( $cart_item_data, $product_id, $variation_id ) {
    if ( !product_is_class( $product_id ) ) return $cart_item_data;
  
    // Save the date, or give a fatal warning. Date is required.
    if ( !empty($_REQUEST['class-date']) ) {
      $cart_item_data['class-date'] = stripslashes($_REQUEST['class-date']);
      return $cart_item_data;
    }else{
      wp_die('&lt;h2&gt;Invalid Class Date Selected&lt;/h2&gt;&lt;p&gt;You tried to add a class to your cart, but the date selected was invalid. Please try again.&lt;/p&gt;');
      exit;
    }
  }
  add_filter( 'woocommerce_add_cart_item_data', 'save_class_menu_selection', 10, 3 );
  </code></pre>