Discussions

Get order total

Good day! Thanks for your great work! Tell me please how I can get the value of the order total in SQL query?

Posted: Mar 21, 2011

Comments

Ryan Ryan Szrama on March 21, 2011

If you need to do this, you should query the commerce_order_total table - but really, this is a Field API table, and you shouldn't necessarily be writing direct queries against it unless you know what you're doing. : )

If you can, it's better to load the order and access it like this:

<?php
$order
= commerce_order_load($order_id);
$wrapper = entity_metadata_wrapper('commerce_order', $order);
$total = $wrapper->commerce_order_total->amount->value();
$currency_code = $wrapper->commerce_order_total->currency_code->value();
?>

itpromanager on February 19, 2014

This worked for me for the order total:

$wrapper = entity_metadata_wrapper('commerce_order', $order);
$total = $wrapper->commerce_order_total->amount->value();