• Resolved Leo.Lin

    (@bi1012037)



    I used the following SQL to clear all members’ balances and transaction records on my test site because there were too many records.
    However, test members can still see their previous records until a new transaction is made to update them. Is there a better approach?
    Question: I want to reset this plugin to its initial state with no data at all.

    SQL

    TRUNCATE TABLE wp_woo_wallet_transactions;
    TRUNCATE TABLE wp_woo_wallet_transaction_meta;
Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Subrata Mal

    (@subratamal)

    @bi1012037 Please use the attached code in theme finctions.php file.

    add_filter( 'woo_wallet_transactions_query_args', 'woo_wallet_transactions_query_args_callback', 10, 1 );
    if ( ! function_exists( 'woo_wallet_transactions_query_args_callback' ) ) {
    	function woo_wallet_transactions_query_args_callback( $args ) {
    		$args['nocache'] = true;
    		return $args;
    	}
    }
    
    Thread Starter Leo.Lin

    (@bi1012037)

    @subratamal
    The records in the member area have been successfully cleared, but in the admin backend, users with zero balances are still listed and have not been removed.

    • This reply was modified 6 months, 2 weeks ago by Leo.Lin.
    Plugin Author Subrata Mal

    (@subratamal)

    @bi1012037 Please use the code.

    Thread Starter Leo.Lin

    (@bi1012037)

    @subratamal
    The cache for the member area in functions.php has been successfully cleared. However, I haven’t seen the code for clearing zero-balance members in the backend(Admin Page). Could you please provide it again? Thank you very much!

    Plugin Author Subrata Mal

    (@subratamal)

    @bi1012037 Use this code to remove zero balance user from admin area.

    add_filter( 'woo_wallet_users_list_table_query_args', 'woo_wallet_users_list_table_query_args_callback', 10, 1 );
    if ( ! function_exists( 'woo_wallet_users_list_table_query_args_callback' ) ) {
    	function woo_wallet_users_list_table_query_args_callback( $args ) {
    		$args['meta_query'] = array(
    			array(
    				'key'     => '_current_woo_wallet_balance',
    				'value'   => '0',
    				'compare' => '>',
    			),
    		);
    		return $args;
    	}
    }
    Thread Starter Leo.Lin

    (@bi1012037)

    @subratamal

    Thank you, I achieved the filtering of empty values and values equal to 0 like this.

    Additionally,I also need to add additional SQL to complete this functionality.

    This issue has been successfully resolved.

    #SQL Script
    TRUNCATE TABLE wp_woo_wallet_transactions;
    TRUNCATE TABLE wp_woo_wallet_transaction_meta;
    UPDATE wp_usermeta SET meta_value = '0' WHERE meta_key = '_current_woo_wallet_balance';
    
    //Close cache. PHP Script
    $nocache =true; //Prevent cleared transaction records from reappearing.
    
    //The modified filtering method. PHP Script
                        $args = array_merge(
                            $args,
                            array(
                                'meta_query' => array(
                                    'relation' => 'AND',
                                    array(
                                        'key' => '_current_woo_wallet_balance',
                                        'value' => '',
                                        'compare' => '!=', //meta_value != null
                                        'type' => 'CHAR',  
                                    ),
                                    array(
                                        'key' => '_current_woo_wallet_balance',
                                        'value' => '0',
                                        'compare' => '>', 
                                        'type' => 'NUMERIC', 
                                    ),
                                ),
                            )
                        );
    • This reply was modified 6 months, 2 weeks ago by Leo.Lin.
    • This reply was modified 6 months, 2 weeks ago by Leo.Lin.
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘How can I quickly initialize records and balances for all members?’ is closed to new replies.