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 | |
/** | |
* Plugin Name: Filter Orders by currency | |
* Description: Adds the ability to filter orders by currency. | |
* Author: Gilles Goetsch | |
* Author URI: https://gillesgoetsch.ch/ | |
* Version: 1.0.0 | |
* Text Domain: wc-filter-orders | |
* Reference: http://www.skyverge.com/product/woocommerce-filter-orders/ |
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
/** | |
* WC API v3 - add functionality to filter by order_currency | |
* example request: /wp-json/wc/v3/orders?status=processing&per_page=-1¤cy=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', |