-
-
Save jorgeatorres/e0e12088756425d3d15762864f18bea1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'pre_option_woocommerce_custom_orders_table_enabled', function() { return 'yes'; } ); | |
add_filter( | |
'woocommerce_order_query', | |
function( $results, $query_vars ) { | |
if ( empty( $_GET['page'] ) || 'wc-orders' !== $_GET['page'] || ! empty( $query_vars['parent'] ) ) { | |
return $results; | |
} | |
global $wpdb; | |
$order_ids = $wpdb->get_col( "SELECT id FROM {$wpdb->prefix}wc_orders ORDER BY id DESC LIMIT 30" ); | |
$orders = array_map( 'wc_get_order', array_map( 'absint', $order_ids ) ); | |
if ( isset( $query_vars['return'] ) && 'ids' === $query_vars['return'] ) { | |
return $order_ids; | |
} | |
if ( empty( $query_vars['paginate'] ) ) { | |
return $orders; | |
} | |
return (object) [ | |
'orders' => $orders, | |
'total' => count( $orders ), | |
'max_num_pages' => 1, | |
]; | |
}, | |
999, | |
2 | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment