Abstract_WC_Order_Data_Store_CPT::get_refund_orders_batch_join_clause
Returns a prepared SQL JOIN clause for finding refund orders belonging to multiple parent orders.
The clause aliases the refund table as refunds. Subclasses should override this to use a different table (e.g. the HPOS orders table).
Method of the class: Abstract_WC_Order_Data_Store_CPT{}
No Hooks.
Returns
string. Prepared SQL JOIN fragment.
Usage
// protected - for code of main (parent) or child class $result = $this->get_refund_orders_batch_join_clause( $order_ids ): string;
- $order_ids(array) (required)
- List of order IDs.
Changelog
| Since 10.7.0 | Introduced. |
Abstract_WC_Order_Data_Store_CPT::get_refund_orders_batch_join_clause() Abstract WC Order Data Store CPT::get refund orders batch join clause code WC 11.1.2
protected function get_refund_orders_batch_join_clause( array $order_ids ): string {
global $wpdb;
$id_list = implode( ', ', array_map( 'absint', $order_ids ) );
// phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- $id_list is sanitized via absint above.
return $wpdb->prepare( "%i AS refunds ON ( refunds.post_type = %s AND refunds.post_parent IN ( $id_list ) )", $wpdb->posts, 'shop_order_refund' );
}