Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save sisaacrussell/9a1eb061aa6e11902ed42763a13dd62e to your computer and use it in GitHub Desktop.
Save sisaacrussell/9a1eb061aa6e11902ed42763a13dd62e to your computer and use it in GitHub Desktop.
add subtotal to edit order admin woocommerce
<?php
// Add to functions.php of your theme or child theme. Don't include the php tag above this line!
/**
* This code will add subtotal to the edit order admin in WooCommerce.
*
* @author Sprucely Designed <support@sprucely.net>
* @see https://github.com/woocommerce/woocommerce/issues/17172
* @param int $order_id Order ID retreived from db for order being displayed.
*/
function sprucely_add_sub_total( $order_id ) {
$order = wc_get_order( $order_id );
?><tr>
<td class="label">Subtotal: <small>(after discount/before shipping & tax)</small></td>
<td width="1%"></td>
<td class="total"><?php echo $order->get_subtotal_to_display(); ?></td>
</tr>
<?php
}
add_action( 'woocommerce_admin_order_totals_after_discount', 'sprucely_add_sub_total', 10, 1 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment