count cancelled vendor orders by shortcode
-
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 ordersreturn count $numorders_cancelled;
}
add_shortcode( ‘count_can_ord’,’pruebashort’);’
The topic ‘count cancelled vendor orders by shortcode’ is closed to new replies.