Woocommerce: Add Customer Orders on My Account Dashboard

Using this code, you can easily add your customers list of orders history to my account dashboard directly. Just paste this code to your theme’s functions.php file.

add_action( 'woocommerce_account_dashboard', 'ec_customer_orders' );
function ec_customer_orders() {
$current_page = empty( $current_page ) ? 1 : absint( $current_page );
$customer_orders = wc_get_orders( apply_filters( 'woocommerce_my_account_my_orders_query', array( 'customer' => get_current_user_id(), 'page' => $current_page, 'paginate' => true ) ) );

wc_get_template(
'myaccount/orders.php',
array(
'current_page' => absint( $current_page ),
'customer_orders' => $customer_orders,
'has_orders' => 0 < $customer_orders->total,
)
);
}

One Comment

  1. May 21, 2019 at 1:49 pm

    Word great! I did move Line 1 to line 15.

Leave A Comment

%d bloggers like this: