Title: Cannot get_refunds() in PHP
Last modified: June 22, 2023

---

# Cannot get_refunds() in PHP

 *  Resolved [Machine IT Services](https://wordpress.org/support/users/machineitsvcs/)
 * (@machineitsvcs)
 * [2 years, 11 months ago](https://wordpress.org/support/topic/cannot-get_refunds-in-php/)
 * I am unable to use the get_refunds() function to get orders reliably in PHP. 
   The function returns an empty array, and even the separate get_qty_refunded_for_item(
   $item_id) returns 0 at the same time, when I know there are refunds, and I can
   get them at a later time. I’m trying to figure out what function needs to be 
   called for these refunds to be available prior to my calling the get_refunds 
   function, as my best guess is that they are being made available slightly later.
   As a test, I added “error_log(json_enocde((bool) $this->refunds));” within the
   get_refunds function, after $this->refunds is set using the wc_get_refunds query,
   and on order page load, it first returns false, and then returns true after page
   load. However, I’m trying to call get_refunds during the “init” and “add_meta_boxes”
   actions, so I can’t wait until after page load. I’d like to know how to make 
   this information available sooner if possible.
    -  This topic was modified 2 years, 11 months ago by [Machine IT Services](https://wordpress.org/support/users/machineitsvcs/).

Viewing 1 replies (of 1 total)

 *  Thread Starter [Machine IT Services](https://wordpress.org/support/users/machineitsvcs/)
 * (@machineitsvcs)
 * [2 years, 11 months ago](https://wordpress.org/support/topic/cannot-get_refunds-in-php/#post-16844615)
 * I was able to find a workaround to do what I was trying to do.

Viewing 1 replies (of 1 total)

The topic ‘Cannot get_refunds() in PHP’ 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/)

 * 1 reply
 * 1 participant
 * Last reply from: [Machine IT Services](https://wordpress.org/support/users/machineitsvcs/)
 * Last activity: [2 years, 11 months ago](https://wordpress.org/support/topic/cannot-get_refunds-in-php/#post-16844615)
 * Status: resolved