Forked from vidishpurohit/gist:4973f69cc21ef34ca4271d26f38dacbf
Last active
July 3, 2020 05:36
-
-
Save sisaacrussell/9a1eb061aa6e11902ed42763a13dd62e to your computer and use it in GitHub Desktop.
add subtotal to edit order admin woocommerce
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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