Title: Detecting refunded orders
Last modified: August 31, 2016

---

# Detecting refunded orders

 *  [SimonGiddings](https://wordpress.org/support/users/simongiddings/)
 * (@simongiddings)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/detecting-refunded-orders/)
 * I am building a plugin to output accounting data to be sent to my accountant 
   where I need to show sales.
    I have now got the situation where I need to indicate
   a refund.
 * How can I detect when an order has been refunded – all or partially – and then
   get the amount of the refund.
 * Obviously, as this output is month based, I need to be able to see the refund
   during the month that it was done, as an order could be placed one month and 
   then the refund come in during the following month.
    For example : order paid
   at the end of March and then refunded in April.
 * How can I do this correctly ?
 * [https://wordpress.org/plugins/woocommerce/](https://wordpress.org/plugins/woocommerce/)

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

 *  Plugin Contributor [Mike Jolley](https://wordpress.org/support/users/mikejolley/)
 * (@mikejolley)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/detecting-refunded-orders/#post-7253656)
 * How are you getting orders currently? Refunds are a kind of order too, but created
   separately when performed.
 *  Thread Starter [SimonGiddings](https://wordpress.org/support/users/simongiddings/)
 * (@simongiddings)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/detecting-refunded-orders/#post-7253683)
 * Hi Mike,
 * I am getting them via a WP_Query call, using the following args :
    ‘post_type’
   => ‘shop_order’, ‘posts_per_page’ => -1, ‘post_status’ => ‘completed’, ‘date_query’
   => array( … date specifics here … ), ‘order’ => ‘ASC’, ‘orderby’ => ‘date’
 * Should I be expanding the post_type to include ‘shop_order_refund’ ?
    If so, 
   how do I link it to the original order ?
 *  Plugin Contributor [Mike Jolley](https://wordpress.org/support/users/mikejolley/)
 * (@mikejolley)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/detecting-refunded-orders/#post-7253756)
 * The query would need to be on shop_order_refund, and the post_parent of the refund
   is how it’s linked to the original order. You’d probably need to check for refund
   existence when looping over the orders you queried.

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

The topic ‘Detecting refunded orders’ is closed to new replies.

 * ![](https://ps.w.org/woocommerce/assets/icon.svg?rev=3234504)
 * [WooCommerce](https://wordpress.org/plugins/woocommerce/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce/reviews/)

## Tags

 * [order](https://wordpress.org/support/topic-tag/order/)

 * 3 replies
 * 2 participants
 * Last reply from: [Mike Jolley](https://wordpress.org/support/users/mikejolley/)
 * Last activity: [10 years, 1 month ago](https://wordpress.org/support/topic/detecting-refunded-orders/#post-7253756)
 * Status: not resolved