• Resolved denia11

    (@denia11)


    Hello everybody,
    I would like to display the amount a user has pledged for a campaign. Ideally, I would like to implement it into a widget where it would show for each logged-in user how much they pledged per campaign.

    I have found a total spent widget for woocommerce that looks like this:

    add_shortcode('user_total_spent', 'get_user_total_spent');
    
    function get_user_total_spent( $atts ) {
        extract( shortcode_atts( array(
            'user_id' => get_current_user_id(),
        ), $atts, 'user_total_spent' ) );
    
        if( $user_id > 0 ) {
            $customer = new WC_Customer( $user_id ); // Get WC_Customer Object
    
            $total_spent = $customer->get_total_spent(); // Get total spent amount
    
            return wc_price( $total_spent ); // return formatted total spent amount
        }
    }
    
    // USAGE: [user_total_spent] or [user_total_spent user_id="118"]

    I couldn’t figure out how to change it to the total spent per product id.
    Could anyone give me a hand or recommend an easier way?
    Thank you in advance,
    Best Regards,
    Denia

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hello @denia11!

    You can check the fund-raised.php file template, in this location
    wpcftemplate/woocommerce/basic/include/fund-raised.php. Then, you will get an idea.

    Need some custom work to get the total spent per product id, this type of custom work is not under support policy, hope you will understand.

    Thank you!

    Plugin Support Md. Jobayer Al Mahmud

    (@jobayertuser)

    Hello @denia11,

    Unfortunately, we can’t provide any custom solution. Our support doesn’t allow us to provide the custom solution we are very sorry I can’t help you.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Display pledged amount per Campaign’ is closed to new replies.