Skip to content

Instantly share code, notes, and snippets.

@ChromeOrange
Last active August 29, 2015 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChromeOrange/4dc8a8efadf6b67cbc29 to your computer and use it in GitHub Desktop.
Save ChromeOrange/4dc8a8efadf6b67cbc29 to your computer and use it in GitHub Desktop.
get_pdf_order_totals
/**
* [get_pdf_order_totals description]
* New for Version 1.3.0, replaces several functions with one looped function
* @param [type] $order_id [description]
* @return [type] [description]
*/
function get_pdf_order_totals( $order_id ) {
global $woocommerce;
if (!$order_id) return;
$order = new WC_Order( $order_id );
$order_item_totals = $order->get_order_item_totals();
unset( $order_item_totals['payment_method'] );
$output = '';
foreach ( $order_item_totals as $order_item_total ) {
$output .= '<tr>' .
'<td align="right">' .
'<strong>' . $order_item_total['label'] . '</strong></td>' .
'<td align="right"><strong>' . $order_item_total['value'] . '</strong></td>' .
'</tr>' ;
}
$output = apply_filters( 'pdf_template_order_totals' , $output, $order_id );
return $output;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment