Created
June 29, 2018 10:21
-
-
Save malsubrata/674f220ef3e9ef6beb03dcab31c26c6e to your computer and use it in GitHub Desktop.
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
add_filter('woo_wallet_current_balance', 'woo_wallet_current_balance', 10, 2); | |
if(!function_exists('woo_wallet_current_balance')){ | |
function woo_wallet_current_balance($balance, $user_id){ | |
$credit_amount = array_sum(wp_list_pluck(get_wallet_transactions(array('user_id' => $user_id, 'where' => array(array('key' => 'type', 'value' => 'credit')), 'nocache' => true)), 'amount')); | |
$debit_amount = array_sum(wp_list_pluck(get_wallet_transactions(array('user_id' => $user_id, 'where' => array(array('key' => 'type', 'value' => 'debit')), 'nocache' => true)), 'amount')); | |
$balance = $credit_amount - $debit_amount; | |
return $balance; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment