H
H
hypero2018-03-13 13:17:06
WooCommerce
hypero, 2018-03-13 13:17:06

How to change product currency in another Wordpress language?

Hello.
How can I change the product currency in another language on Wordpress.
When I change the language of the site, the currency of the product should change.
How to do it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Drobyshev, 2018-03-13
@antoshadrobyshev

What multilingual plugin are you using? What currency switch plugin are you using?
If 1 is wpml and 2 is woocommerce currency switcher then like this.

add_filter('wp_head', function() {
    $lang = ICL_LANGUAGE_CODE;
    global $WOOCS;
    switch ($lang)
    {
        case 'bg':
            $WOOCS->current_currency = 'BGN';
            $WOOCS->storage->set_val('woocs_current_currency', 'BGN');
            break;
        case 'en':
            $WOOCS->current_currency = 'EUR';
            $WOOCS->storage->set_val('woocs_current_currency', 'EUR');
            break;
        default:
            $WOOCS->current_currency = 'USD';
            $WOOCS->storage->set_val('woocs_current_currency', 'USD');
            break;
    }
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question