woothemes/woocommerce — pull request #5018 by syaiful6 (2014-03-03 07:13:55+00:00)
Title: Implements Iterator and Countable to WC Cart

For WC Cart I think is best to implements Iterator and Countable because WC Cart in the template and on other class such as Shipping Class, we are iterate cart content by access that to WC::get_cart(), now when WC Cart implement Iterator and Countable, the WC Cart object can be iterated. To do it just like this

foreach( WC()->cart as $cart_item_key => $cart_item ) {
//you can get product just like the old method

$_product = $cart_item['data'];
}

To count or check the count of cart content you can do like this `count(WC()->cart)`. It's nice..