Frank Umeadi
Forum Replies Created
-
Forum: Plugins
In reply to: [Wallet for WooCommerce] Total Wallet Balance of All UsersAlright, let me be very clear. Follow the below guideline to implement this feature.
1. Create the Shortcode
Add the following code to your child’s theme functions.php. It is used to create a shortcode that will display the total wallet balance of all users.
//Create shortcode to display total balance add_shortcode( 'total_balance', 'total_balance_shortcode' ); function total_balance_shortcode(){ global $wpdb; $total_balance = $wpdb->get_var(“SELECT DISTINCT SUM(p.meta_value) FROM {$wpdb->prefix}usermeta as p WHERE p.meta_key=’_current_woo_wallet_balance'”); return $total_balance; }2. Create a WordPress Page
Then, create a new WordPress page. You can name it Total Wallet Balance or anything you wish. This page is where you will display the total wallet balance of all users. I believe this feature is only useful to the admin, so you don’t have to allow other users to access it. So don’t create a menu link for it.
Inside the editing area of the page, enter the shortcode [total_balance]. This shortcode will now display the total wallet balance of all users when you open the page.
I hope this guide helps everyone that needs it. Good luck!
Forum: Plugins
In reply to: [Wallet for WooCommerce] Total Wallet Balance of All UsersI have found a way to do it. For anyone still interested in this feature, you can try the below code.
global $wpdb;
$total_balance = $wpdb->get_var(“SELECT DISTINCT SUM(p.meta_value) FROM {$wpdb->prefix}usermeta as p WHERE p.meta_key=’_current_woo_wallet_balance'”);
echo $total_balance;