How can I programatically get the cart's dollar sum of drupal commerce? For future users &lt;?php echo  '$' . number_format(( $total['amount'] /100),2); ?&gt; is how.



Following this guide http://kahthong.com/2012/08/programmatically-show-number-items-drupal-commerce-shopping-cart I got the cart item total using

&lt;?php
global $user;
$quantity = 0;
$order = commerce_cart_order_load($user-&gt;uid);
if ($order) {
    $wrapper = entity_metadata_wrapper('commerce_order', $order);
    $line_items = $wrapper-&gt;commerce_line_items;
    $quantity = commerce_line_items_quantity($line_items, commerce_product_line_item_types());
    $total = commerce_line_items_total($line_items);
    $currency = commerce_currency_load($total['currency_code']);
}
print format_plural($quantity, '1 item', '@count items');
?&gt;


however when I try to get the dollar total using &lt;?php print $total; ?&gt;, it just returns 'Array'. 

I used Devel on the page, but the cart is just a bunch of markup in ['content']['system_main']['main']['#markup']. What I want is &lt;span class="line-item-total-raw"&gt;$106.00&lt;/span&gt;, is there a way I can grab that class specifically with php somehow? Or maybe there's another way to go about this.
You should have it already.  That call to "commerce_line_items_total" returns the array:

return array('amount' =&gt; $total, 'currency_code' =&gt; $currency_code);


Thus you should have the total price at $total['amount'] since you already have $total['currency_code']