Search code examples
phpwordpresswpml

Wordpress WPML - set currency programmatically


I'm using WPML and WooCommerce Multilingual with multicurrency setting. I'm detecting geolocation of visitor via geoplugin.net to set up site language.

I want to set up currency also and here's a question:

Is there a way to set up currency programmatically in WooCommerce Multilingual? I tried do_action('wcml_switch_currency', $_curr); where $_curr = 'GBP';' with no luck :/.


Solution

  • I figured it out via filter, this is example:

    add_filter('wcml_client_currency', 'wcml_custom_currency');
    function wcml_custom_currency($current){
        return 'GBP'; 
    }