WC_API_Orders::get_order_refunds()
Get the order refunds for an order
Method of the class: WC_API_Orders{}
Hooks from the method
Return
Array|WP_Error
.
Usage
$WC_API_Orders = new WC_API_Orders(); $WC_API_Orders->get_order_refunds( $order_id, $fields );
- $order_id(string) (required)
- order ID
- $fields(string|null)
- fields to include in response
Default: null
Changelog
Since 2.2 | Introduced. |
WC_API_Orders::get_order_refunds() WC API Orders::get order refunds code WC 7.7.0
public function get_order_refunds( $order_id, $fields = null ) { // Ensure ID is valid order ID $order_id = $this->validate_request( $order_id, $this->post_type, 'read' ); if ( is_wp_error( $order_id ) ) { return $order_id; } $refund_items = wc_get_orders( array( 'type' => 'shop_order_refund', 'parent' => $order_id, 'limit' => -1, 'return' => 'ids', ) ); $order_refunds = array(); foreach ( $refund_items as $refund_id ) { $order_refunds[] = current( $this->get_order_refund( $order_id, $refund_id, $fields ) ); } return array( 'order_refunds' => apply_filters( 'woocommerce_api_order_refunds_response', $order_refunds, $order_id, $fields, $refund_items, $this ) ); }