Pierre
Pierre

Reputation: 119

How to change Wordpress WooCoocommerce currency format by languages with WPML

I was wondering how to change the currency price format on the front end for a WooCommerce installation based on the language. Is there a simple way to achieve this?

Upvotes: 0

Views: 712

Answers (1)

Pierre
Pierre

Reputation: 119

I have used the following filter woocommerce_price_format.

Here is my code :

add_filter( 'woocommerce_price_format', 'custom_woocommerce_price_format', 10, 2 );
function custom_woocommerce_price_format($format,$currency_pos){
    switch(ICL_LANGUAGE_CODE){
        case 'fr':
            $format = '%2$s %1$s';
        break;
        case 'en':
            $format = '%1$s%2$s';
        break;
    }
    return $format;
}

Upvotes: 2

Related Questions