php – Change WooCommerce currency programmatically on AJAX request

I’m adding a custom ajax_action To fetch a product and display the price html (same template as everywhere else on my page), the issue is that the price being returned is not equal to the current price set by the user.

in my ajax call i have tried to send currency/wcmlc In form of POST/GET parameter but it doesn’t work.

I have also tried various actions that I could find online.

I believe the problem is that the filter wcml_client_currency It’s not effective on AJAX requests, and it’s problematic.

Using the following code:

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

will still return euro on ajax requests/tasks.

Leave a Comment