• Resolved calle81

    (@calle81)


    I would like to know if there is a php snippet that allows me to view how much I have uploaded in total to my wallet.

    Example: Yesterday I top up €20 and today I top up €30.

    I would like a code that shows me:

    Since you signed up, you’ve topped up in your wallet: €50

    Thanks.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter calle81

    (@calle81)

    Can someone help me?

    Thanks.

    Plugin Author Subrata Mal

    (@subratamal)

    @calle81 Please use the attached code in the theme functions.php file and use the shortcode total-diposit to display the total deposit by a user.

    add_shortcode( 'total-diposit', 'total_diposit' );
    function total_diposit() {
    	$args          = array(
    		'user_id'    => get_current_user_id(),
    		'where'      => array(
    			array(
    				'key'   => 'type',
    				'value' => 'credit',
    			),
    		),
    		'where_meta' => array(
    			array(
    				'key'   => '_type',
    				'value' => 'credit_purchase',
    			),
    		),
    	);
    	$transactions  = get_wallet_transactions( $args );
    	$total_diposit = array_sum( wp_list_pluck( $transactions, 'amount' ) );
    	return wc_price( $total_diposit, woo_wallet_wc_price_args() );
    }
    Thread Starter calle81

    (@calle81)

    @subratamal Thanks for the reply, but it’s possible to have the code without creating a shortcode, because I have to put it inside other code. Thanks.

    Plugin Author Subrata Mal

    (@subratamal)

    You can use this code from the function body.

    • This reply was modified 1 year, 8 months ago by Subrata Mal.
    Thread Starter calle81

    (@calle81)

    @subratamal Thanks, it won’t let me see the code.

    Plugin Author Subrata Mal

    (@subratamal)

    $args          = array(
    		'user_id'    => get_current_user_id(),
    		'where'      => array(
    			array(
    				'key'   => 'type',
    				'value' => 'credit',
    			),
    		),
    		'where_meta' => array(
    			array(
    				'key'   => '_type',
    				'value' => 'credit_purchase',
    			),
    		),
    	);
    $transactions  = get_wallet_transactions( $args );
    $total_diposit = array_sum( wp_list_pluck( $transactions, 'amount' ) );
    Thread Starter calle81

    (@calle81)

    @subratamal Thanks, it works perfectly.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Php fragment to view what has been reloaded into the wallet’ is closed to new replies.