Change WooCommerce currency programmatically on AJAX request

Question

I am adding a custom ajax_action to fetch a product and display 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 user.

In my AJAX call I have tried sending currency/wcmlc as a POST/GET parameter but this does not work.

I have also tried different actions I could find online.

I believe the problem is that the filter wcml_client_currency is not effective on AJAX requests, and this is problematic.

Using the following code:

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

Would still return EURO on AJAX requests/actions.

--------------------------------------------------

>>> Share a link to this question, just copy and paste the code bellow on your web page <<<

<a href="https://www.wptricks.com/question/change-woocommerce-currency-programmatically-on-ajax-request/">

Change WooCommerce currency programmatically on AJAX request</a>
0
, , , , FooBar 3 months 0 Answers 85 views 0

Leave an answer