Skip to content

Instantly share code, notes, and snippets.

@webthread
Created January 4, 2018 16:44
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 webthread/9fd801090f1864185e1485b9ec90e56c to your computer and use it in GitHub Desktop.
Save webthread/9fd801090f1864185e1485b9ec90e56c to your computer and use it in GitHub Desktop.
Filter Currencies
add_filter('request', function( $vars ) {
// Check the capability of the current user.
if ( ! current_user_can( 'uk_orders_visible' ) )
return;
global $typenow, $wpdb;
// Add logic to determine if the orders list should be filtered, and which
// currency
$currency = 'GBP';
if($typenow == 'shop_order') {
$vars['meta_query']['relation'] = 'AND';
// Only show orders in the specific currency
$vars['meta_query'] = array(
array(
'key' => '_order_currency',
'value' => $currency,
'compare' => '=',
),
);
}
return $vars;
}, 15 );
add_filter('request', function( $vars1 ) {
// Check the capability of the current user.
if ( ! current_user_can( 'au_orders_visible' ) )
return;
global $typenow, $wpdb;
// Add logic to determine if the orders list should be filtered, and which
// currency
$currency = 'AUD';
if($typenow == 'shop_order') {
$vars1['meta_query']['relation'] = 'AND';
// Only show orders in the specific currency
$vars1['meta_query'] = array(
array(
'key' => '_order_currency',
'value' => $currency,
'compare' => '=',
),
);
}
return $vars1;
}, 15 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment