Created
October 31, 2018 12:47
-
-
Save vanbo/8030668f409882fcbdd44928fbecf165 to your computer and use it in GitHub Desktop.
woocommerce-linnworks-request-allow-only-processing-orders
This file contains hidden or 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
| 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