title: WooCommerce - new shipping method - how to query individual product weights
body: <p>I'm writing a plugin for <strong>WooCommerce</strong> that creates a custom shipping option using my own algorithm.</p>
  
  <p>I'm new to object oriented programming though, and am a big confused on how to properly access methods/classes outside of the one I'm in.</p>
  
  <p>Right now there is a class called calculate_shipping() that WooCommerce uses.  Basically, my new shipping method extends the WC_Shipping_Method class to add this new one.</p>
  
  <p>My question is this: </p>
  
  <p>Within <code>my_new_shipping_class()-&gt;calculate_shipping()</code> , what's the correct way to query the following?</p>
  
  <ol>
  <li>Return a list of all products in the shopping cart array and their associated weight</li>
  <li>Access the current zip code that the user has entered in their cart</li>
  </ol>
  
  <p>From some digging I know there is an array called $cart_contents that seems to contain everything I need. (maybe not the weight though?)</p>
  
  <p>This is under <code>WC_Cart-&gt;get_cart()</code> , though there is also some kind of public array called $cart_contents.  What is the correct way to access either of these?</p>
  
  <p>Individual product weights can also be found under <code>WC_Product-&gt;get_weight()</code>, but I'm not sure if I have to use that.</p>
  
  <p>Ultimately, what I'm looking to return is a sorted array of each product weight.  For example, say the cart has the following:</p>
  
  <ul>
  <li>Item 1, QTY: 1, 2lbs each</li>
  <li>Item 2, QTY: 2, 5lbs each</li>
  <li>Item 3, QTY: 1, 10lbs each</li>
  </ul>
  
  <p>I'd like to return an array with [10,5,5,2]  so I can then run an algorithm that places those products in boxes with maximum weights and returns individual shipping costs on each box.</p>
  
  <p>Most of this question is probably around basic object oriented programming, so sorry if it comes off as a dumb question.</p>