WOOCS - WooCommerce Currency Switcher Professional


Disable woocommerce products for one specific currency

If it is necessary to hide products from shop for one or more currencies you can use next code in file functions.php of the current WordPress theme:

add_action('pre_get_posts', function ($query) {
    woocs_products_hide($query);
}, 1, 99999);

add_action('woocommerce_product_query', function ($query, $that) {
    woocs_products_hide($query);
}, 10, 2);

function woocs_products_hide($query) {
    if (isset($query->query['post_type']) AND $query->query['post_type'] === 'product') {
        global $WOOCS;
        if ($WOOCS AND $query->is_main_query()) {
            switch ($WOOCS->current_currency) {
                case 'USD':
                    $query->set('post__not_in', [83]);
                    break;
                case 'EUR':
                    $query->set('post__not_in', [33, 44]);
                    break;
            }
        }
    }
}