Skip to content

Instantly share code, notes, and snippets.

@barryhughes
Last active September 9, 2024 21:46
Show Gist options
  • Save barryhughes/07d7cf478bab35b83cc3687578f7d058 to your computer and use it in GitHub Desktop.
Save barryhughes/07d7cf478bab35b83cc3687578f7d058 to your computer and use it in GitHub Desktop.
WooCommerce > REST API > Orders > IDs Only
<?php
add_filter(
'rest_post_dispatch',
function ( $response, $server, $request ) {
if (
$request->get_route() === '/wc/v3/orders'
&& $request->get_param( '_fields' ) === [ 'id' ]
&& $request->get_param( '_vendor' ) === 'flag'
) {
$response->set_data( wp_list_pluck( $response->get_data(), 'id' ) );
}
return $response;
},
100,
3
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment