Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Contributor Mike Jolley

    (@mikejolley)

    That plugin won’t do it. You need a custom query.

    You can base yours on this one in core which counts all order statuses for a user:

    https://docs.woothemes.com/wc-apidocs/source-function-wc_get_customer_order_count.html#

    Thread Starter kronoswolf

    (@kronoswolf)

    Sorry for the late reply and thank you for your help! I’m not an expert in php, but it’s working for me.

    If someone has the same problem, this is the code I am using, put the code in functions.php

    //Count and display the pending payments in My Account
    function wc_get_customer_orders() {
    
        // Get pending customer orders
        $customer_orders = get_posts( array(
            'numberposts' => -1,
            'meta_key'    => '_customer_user',
            'meta_value'  => get_current_user_id(),
            'post_type'   => wc_get_order_types(),
            'post_status' => 'wc-pending',
        ) );
    
        if ( count( $customer_orders ) == 0 ) {
    
        echo 'No pending payments';
        } else {
    
        echo count( $customer_orders ), ' pending payments';
      }
    
    }
    add_action( 'woocommerce_before_my_account', 'wc_get_customer_orders' );
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Display number of pending orders for the customer’ is closed to new replies.