FOX - Currency Switcher for WooCommerce

So blenden Sie Produkte für eine bestimmte Währung aus

Falls es notwendig ist, Produkte für eine oder mehrere Währungen aus dem Shop auszublenden, können Sie den folgenden Code in der Datei functions.php des aktuellen WordPress-Themes verwenden:
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;
            }
        }
    }
}