Skip to content

Instantly share code, notes, and snippets.

@damiencarbery
Created November 15, 2016 10:41
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 damiencarbery/b01895dd847acc0d7630dcfee35f02e2 to your computer and use it in GitHub Desktop.
Save damiencarbery/b01895dd847acc0d7630dcfee35f02e2 to your computer and use it in GitHub Desktop.
<?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