The documentation on wc_get_orders
and WC_Order_Query
is poor… Now regarding the order status in a WC_Order_Query
, you can pass an array of order statuses:
// Display "completed" orders count
$statuses = ['completed'];
$orders = wc_get_orders( ['limit' => -1, 'status' => $statuses] );
echo '<p>' . sprintf( __('Count of "%s" orders: %s'), implode('", "', $statuses), count($orders) ) . '</p>';
// Display "refunded" orders count
$statuses = ['refunded'];
$orders = wc_get_orders( ['limit' => -1, 'status' => $statuses] );
echo '<p>' . sprintf( __('Count of "%s" orders: %s'), implode('", "', $statuses), count($orders) ) . '</p>';
// Display "completed" and "refunded" orders count
$statuses = ['completed','refunded'];
$orders = wc_get_orders( ['limit' => -1, 'status' => $statuses] );
echo '<p>' . sprintf( __('Count of "%s" orders: %s'), implode('", "', $statuses), count($orders) ) . '</p>';
Tested and works.
Related Posts:
- How to trigger WooCommerce order complete email?
- How to automatically apply woocommerce product title to all product images alt tags?
- How to have a custom display for both woocommerce archive and product-category pages? [closed]
- Woocommerce auto cancel On-Hold after X days
- How to remove “out of stock” variation options from size dropdown in woocommerce?
- WP_Query | Help me create a search term with an ‘OR’ relation?
- WooCommerce – Customer Order History Pagination
- The values of custom fields are not available functions.php
- Use wc_enqueue_js only on specific pages – nested add_action
- Get WooCommerce shipping methods programmatically
- Add a custom text field to WooCommerce admin product data “Variations”
- Translating add to cart woocommerce button [closed]
- Display related products with custom output
- Add attribute / custom attribute to product in woocommerce
- Use is_product_category() properly
- Changing Woocommerce flat rate every nth number of items
- How to select WooCommerce products by post_meta and order them
- Help with some php math in WordPress
- How do I display a user’s previous orders as a select box option on a product?
- write custom woocommerce templates and forms
- combine Code 1 with Code 2
- WooCommerce – Email admin with new user details
- Automated Cart Update With Alert Box Each Time
- Two Different Links for Same Product – WooCommerce [closed]
- Issue adding sub category programmatically
- WooCommerce/WordPress: how hide entire table form after submit (Admin Dashboard)?
- Show prices with tax in Woocommerce Mini Cart [closed]
- Auto-update products after they were published – Woocommerce
- How to VAR_DUMP a $variable during checkout process (Is my product meta callable?)
- Reload part of checkout on changed shipping method
- Woocommerce related product text
- Which field should I edit to make the checkbox marked by default?
- wordpress + woocommerce display product with additional information [closed]
- Function works when I don’t login to WordPress but when I login then it doesn’t work
- How to make products with no cost in WooCommerce
- How to remove woocommerce_breadcrumb() from do_action( ‘woocommerce_before_main_content’ ); [closed]
- Add post with approval by the admin
- Woocommerce display one random product via php
- Change product_base programmatically
- How to optimize update_post_meta?
- Add product to cart for user – WC()->cart->add_to_cart [closed]
- customize woocommerce templates and display store on home
- WC_Customer delete function returns error
- Display attribute on shop page after the title
- CSS change in woo commerce Place Order Text [closed]
- WooCommerce – Moving Product Price to the Left of Add to Cart Button [closed]
- Exclude product attributes from taxonomy terms loop
- WP All Import / Update stock quantity from multiple XML files
- Woocommerce: remove total sum from new order’s email [closed]
- WordPress WP_Query without query GET parameters
- Where to copy woocommerce files to in my custom theme to avoid editing the core plugin?
- Alter Woocommerce product archive structure
- Have Woocommerce show product price if id, when not logged in
- custom post type with role Vendor
- WooCommerce: Display product categories to make IF statement
- Modify WooCommerce used to get all orders in dashboard
- Replace category title with category description in woocommerce
- Add Custom Category Description When Empty
- I am having issue in divi woocomerce checkout module. (DIVI theme)
- Add a product category to a specific product via a button
- WooCommerce Query Product Titles
- Woocommerce display orders with products from specific categories to specific admins
- Display div if category has a specific parent
- global $product is empty string when passed into function
- Variant Item SKU as Product Code
- Run a sql (update) after 12 hours after the user login. Woocommerce users
- Use PHP Class in WordPress functions
- Add a new view on the Woocommerce account page
- Use Search Term in html link and redirect
- Don’t update modified post date when user add a product review or comment?
- How do I change the “login” label in My Account page to “Registered Customer”
- Customize the “Available for back order” text for specific variation
- How to remove the replace the product image by video on shop page conditionally
- How to get content on a blank basket/cart page in a custom theme with woocommerce
- get_filtered_term_product_counts – Get product terms if any products
- How to import woocommerce custom fields data into another site?
- How to add custom attribute to all outofstock and all instock products automatically?
- Site infected by link
- Woocommerce – if selected attribute term equals
- split 1 cart item into instock and back ordered
- Need to forward Data from WooCommerce Webhook sent to same site WordPress REST API custom endpoint
- Add Product Permalink in woocommerce admin order page
- sessionStorage saves input value in browser but it is not loaded in the form field
- WooCommerce – Add Shipping class below each product in Shopping Cart page
- Hide price excluding tax when price is empty
- WooCommerce Custom Tab with ACF Repeater Field
- Woocommerce variation with radio button + price
- Display product attributes for current product
- How to remove image on single product and get product to span page?
- Adding placeholder text field to woocommerce checkout [closed]
- Getting custom field data from cart page to checkout page in woocomerce [closed]
- Send a custom notification to customer on WooCommerce cancelled order status
- How to code bulk order form in wordpress
- Custom field fetch error on woocommerce pdf invoice
- posts_clauses drop ACF get_field function
- WCFM Custom form
- Find owner of coupon
- Add Woocommerce Customers link to custom admin menu
- PayPal button not showing and cannot retrieve order error in PayPal
- Add text below WooCommerce short description if metabox value is true