Created
November 15, 2016 10:41
-
-
Save damiencarbery/b01895dd847acc0d7630dcfee35f02e2 to your computer and use it in GitHub Desktop.
Sample code for boards.ie thread - http://www.boards.ie/vbulletin/showthread.php?t=2057669869
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 | |
/* | |
Plugin Name: WooCommerce Order History Test | |
Plugin URI: http://www.damiencarbery.com | |
Description: Quick experiment with adding order history info to My Orders tab. | |
Author: Damien Carbery | |
Version: 0.1 | |
$Id: $ | |
*/ | |
add_action('woocommerce_after_account_orders', 'woh_order_summary'); | |
function woh_order_summary($has_orders) { | |
if ($has_orders) { | |
echo '<p>This is where we add the order history info</p>'; | |
$customer_orders = wc_get_orders( array( 'customer' => get_current_user_id(), 'page' => $current_page, 'paginate' => true ) ); | |
$orders_total = 0; | |
foreach ( $customer_orders->orders as $customer_order ) { | |
$order = wc_get_order( $customer_order ); | |
//$order->get_formatted_order_total() | |
$orders_total += $order->get_total(); | |
} | |
if ($orders_total) { | |
printf('<p>You have spent a total of %s in this online shop.</p>', wc_price($orders_total)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment