-
-
Save webthread/9fd801090f1864185e1485b9ec90e56c to your computer and use it in GitHub Desktop.
Filter Currencies
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
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