Skip to content

Instantly share code, notes, and snippets.

@gillesgoetsch
Last active April 20, 2020 12:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gillesgoetsch/d44eba487ee3e5d742ad71cffea3e5e9 to your computer and use it in GitHub Desktop.
Save gillesgoetsch/d44eba487ee3e5d742ad71cffea3e5e9 to your computer and use it in GitHub Desktop.
WC API v3 - add functionality to filter by order_currency
/**
* WC API v3 - add functionality to filter by order_currency
* example request: /wp-json/wc/v3/orders?status=processing&per_page=-1&currency=EUR
*/
add_filter( 'woocommerce_rest_orders_prepare_object_query', 'theme_woocommerce_rest_orders_prepare_object_query', 10, 2 );
function theme_woocommerce_rest_orders_prepare_object_query( $args, $request ){
$args['meta_query'][] = array(
'key' => '_order_currency',
'value' => $request['currency'],
'compare' => 'LIKE'
);
return $args;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment