• Resolved supportgc

    (@supportgc)


    Hello, i need help with a code to count the cancelled orders by short code

    code example

    ‘function pruebashort(){
    $current_user = wp_get_current_user();
    $numorders = wc_get_customer_order_count( $current_user->ID );

    $args = array(
    ‘customer_id’ => $current_user->ID,
    ‘post_status’ => ‘cancelled’,
    ‘post_type’ => ‘shop_order’,
    ‘return’ => ‘ids’,
    );
    $numorders_cancelled = 0;
    $numorders_cancelled = count( wc_get_orders( $args ) ); // count the array of orders

    return count $numorders_cancelled;
    }
    add_shortcode( ‘count_can_ord’,’pruebashort’);’

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘count cancelled vendor orders by shortcode’ is closed to new replies.