Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save vanbo/8030668f409882fcbdd44928fbecf165 to your computer and use it in GitHub Desktop.

Select an option

Save vanbo/8030668f409882fcbdd44928fbecf165 to your computer and use it in GitHub Desktop.
woocommerce-linnworks-request-allow-only-processing-orders
add_filter( "woocommerce_rest_shop_order_object_query", 'prefix_filter_orders', 5, 2 );
/**
* @param $args
* @param WP_REST_Request $request
*
* @return mixed
*/
function filter_orders( $args, $request ) {
$get_params = $request->get_query_params();
// Validate in some way that this is a Linnworks request
// Maybe using the "oauth_consumer_key", if you know it.
if ( 'ck_ca305de81e9df5roa03fka933688e54bdde625' != $get_params['oauth_consumer_key'] ) {
return $args;
}
// If the status is not set or is something other than 'processing', set it to processing
if ( ! isset( $get_params['status'] ) || 'processing' != $get_params['status'] ) {
$get_params['status'] = 'processing';
$request->set_query_params( $get_params );
}
return $args;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment