@christigiano1 Thanks for reaching out. Do you want to display the sum of all user’s current balances?
@subratamal Thank you, not the sum of all user balances. I want each user to be able to see their all time amount spent on the store on the dashboard, is that possible?
So you mean the total debited amount from the user wallet?
@subratamal Exactly, that is what i want, is there a ay i can get that done?
You will get all debited amounts using the below function.
$debit_amount = array_sum(wp_list_pluck( get_wallet_transactions( array( 'user_id' => get_current_user_id(), 'where' => array( array( 'key' => 'type', 'value' => 'debit' ) ) ) ), 'amount' ) );
please how can i put this into their dashboard? i am having trouble doing it.
You can override wc-endpoint-wallet.php template file into the theme folder and write the code.
@subratamal thank you for your kind support but i am finding it hard integrating this code so the total debit amount can display on each user account.
Please try the attached code in the theme function.php file.
add_action('woo_wallet_before_my_wallet_content', 'woo_wallet_before_my_wallet_content_callback');
if(!function_exists('woo_wallet_before_my_wallet_content_callback')){
function woo_wallet_before_my_wallet_content_callback(){
$debit_amount = array_sum(wp_list_pluck( get_wallet_transactions( array( 'user_id' => get_current_user_id(), 'where' => array( array( 'key' => 'type', 'value' => 'debit' ) ) ) ), 'amount' ) );
echo sprintf('Total spent %s', wc_price($debit_amount));
}
}
i dont know if it is the theme i am using but i have also tried to put this in the function.php file and it still remains without a change, there is no column or feature added that shows total debited amount.