Created
January 27, 2018 16:25
-
-
Save UltimateWoo/416c24e82a5d195134f84094cd7a845b to your computer and use it in GitHub Desktop.
Add new table row to WooCommerce cart/checkout totals
This file contains hidden or 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_action( 'woocommerce_cart_totals_after_order_total', 'uw_display_cart_totals_after' ); | |
add_action( 'woocommerce_review_order_after_order_total', 'uw_display_cart_totals_after' ); | |
/** | |
* Pulls in cart totals and adds a new table row to the cart/checkout totals | |
* | |
* @author UltimateWoo - https://www.ultimatewoo.com | |
*/ | |
function uw_display_cart_totals_after() { | |
// Future payments | |
$deposits = WC_Deposits_Cart_Manager::get_instance(); | |
$future_payments = $deposits->get_future_payments_amount(); | |
// Cart total | |
$cart_total = WC()->cart->get_total( '' ); | |
// Final calculated total (future + current) | |
$final_total = $future_payments + $cart_total; | |
?> | |
<tr class="order-total" id="final-total"> | |
<th><?php _e( 'Final Total', 'ultimatewoo-pro' ); ?></th> | |
<td><?php echo wc_price( $final_total ); ?></td> | |
</tr> | |
<script> | |
jQuery(document).ready(function($) { | |
$('#final-total').insertBefore( '.shop_table .cart-subtotal' ); | |
}); | |
</script> | |
<?php | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment