Get The Correct WooCommerce Product Price in AJAX Call When Using WPML

It was recently brought to my attention that when using my WooCommerce QuickView plugin with WPML, everything was translated correctly except the price. If multi currency was enabled, the price was still displayed in the default store currency.

After looking into this for a while, I found the solution and felt it was worth sharing, although probably a very niche issue.

The solution is to enable multi currency in your AJAX action using a filter provided by WPML.

You can drop this code into your plugin or theme, or for the less experienced, try using theĀ Code Snippets plugin.

The function accepts one parameter, $ajax_actions. This is an array of AJAX actions where multi currency should be applied.

Simply add your AJAX action to the array and return the results. Your prices will now be converted to the correct currency.

James is the founder of Iconic and an experienced WooCommerce plugin developer.


1 Comment

  1. Ajay Radadiya says:

    Call for Price for WooCommerce customer direct contact to seller with url or whatsapp number Woocommerce call for price plugin

Leave a Reply

Your email address will not be published. Required fields are marked *