Skip Navigation

This thread is resolved. Here is a description of the problem and solution.

Problem:
I'm using Elementor Pro and the widget Mini Cart to display items and currency added to the cart. The second currency will display based on the user's location. It is set up in WooCommerce > WooCommerce Multilingual & Multicurrency > Multicurrency > Currency section > Client Location.
But the currency in the Mini Cart always displays the default currency even if the client adds a product to the cart with the second currency.
Solution:
Add the code below to the file functions.php in the theme/child theme folder to fix the issue.

add_filter( 'wcml_multi_currency_ajax_actions', 'add_action_to_multi_currency_ajax', 10, 1 );
function add_action_to_multi_currency_ajax( $ajax_actions ) {
    $ajax_actions[] = 'elementor_menu_cart_fragments'; // Add a AJAX action to the array
    return $ajax_actions;
}

Relevant Documentation:
https://wpml.org/wcml-hook/wcml_multi_currency_ajax_actions/

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

Tagged: 

This topic contains 9 replies, has 2 voices.

Last updated by blazejS-3 1 year, 8 months ago.

Assisted by: Long Nguyen.

Author Posts
April 19, 2023 at 6:54 am #13501865

blazejS-3

I have a problem , the price is displayed according to the location. And it displays correctly everywhere except the mini cart. There, after adding a product, for example, with the currency of PLN displaying the page from the Polish, the price for a moment is shown in PLN literally for a few seconds and changes to the price in USD. I have tried everything including this https://wpml.org/forums/topic/mini-cart-not-showing-correct-currency/ but they do not help. Link to yoxconcept.com

April 20, 2023 at 7:21 am #13509035

Long Nguyen
Supporter

Languages: English (English )

Timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Hi Blazej,

Thank you for contacting WPML support, I'd be happy to help you with this issue.

I see that issue on your site. Can you please let me know which plugin you are using to create the mini cart? It looks like a custom code, isn't it?

You can try to enable a minimal environment as below and see if it helps:
- Deactivate all plugins except WPML plugins, WooCommerce, Elementor.
- Switch to a standard theme of WordPress.
❌ IMPORTANT: Please backup your database and website before proceeding ❌
You can use this plugin to create the backup: 
https://wordpress.org/plugins/duplicator/

I also need more information on your site by sharing the debug info. If you don’t know how to share the debug info, please follow this article https://wpml.org/faq/provide-debug-information-faster-support/
Your next reply is enabled to share the debug info.

Look forward to your reply.
Thanks

April 20, 2023 at 7:54 am #13509277

blazejS-3

I am using the mini cart widget for elementor. It looks like elementor is fetching default price from WMPL multicurrency. As we analysed the request it looks like admin-ajax.php is called by elemnentor and it includes updated cart fragment with default price (USD instead of polish zloty). Elementor said we have to contact you because “it seems like the WPML conditional logic functionality for currency is not compatible with Elementor. As we do not have any control over third-party plugins and its code and functionality i would advise you to please contact WPML support as they will be in the best position to help you out with the issue.“. Please be kind to help us since the Elementor support looks like they don’t care :disappointed:

April 20, 2023 at 9:36 am #13510179

Long Nguyen
Supporter

Languages: English (English )

Timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Hi,

Thank you for your feedback.

Firstly, please update WPML plugins to the newest version on your site and check this issue again. Kindly follow the documentation https://wpml.org/faq/install-wpml/#checking-for-updates

If the issue persists, to be able to report the compatibility issues we need to replicate the issue on a clean installation. I created a clean installation of WordPress, WPML, and all necessary WPML add-ons. You can access the WordPress dashboard using the link below:
hidden link

Kindly follow the steps below:

- Install Elementor and WooCommerce plugins.
- Try to replicate the issue.
- Then let me know the steps to replicate it.

This will help us to report the probable issue to the compatibility team and solve the possible problem faster.

Look forward to your reply.
Thanks

April 20, 2023 at 10:18 am #13510591

blazejS-3

The plug-ins were updated, however, this did not help.
I installed elementor and elemntor pro and woocommerce. I placed the widget we use in heder and added one test product. In Networking I can already observe two ajax files responsible for the price refresh. These are :
wc-ajax get_refreshed_fragments
admin-ajax.php where the action elementor_menu_cart_fragments
To duplicate the steps you would need to use WooCommerce Multilingual & Multicurrency to set 3 different prices for products in USD as base currency. In EUro for Europe and in PLN for Poland. Set Show currencies based on: Client Location. After that you would need to access the site from a European or Polish ip number and check if the problem still exists

Screenshot 2023-04-20 at 12.17.27.png
Screenshot 2023-04-20 at 12.16.57.png
April 21, 2023 at 3:38 am #13514843

Long Nguyen
Supporter

Languages: English (English )

Timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Hi,

Thank you for your feedback.

I can replicate the issue on the sandbox site. I'm asking my 2nd tier support about this issue and update you here when I have something to share.

Thanks for your patience.

April 21, 2023 at 6:31 am #13515095

blazejS-3

Thank you very much I am waiting for a reply

April 21, 2023 at 7:15 am #13515335

Long Nguyen
Supporter

Languages: English (English )

Timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Hi,

Thank you for your feedback.

I got some information from our 2nd tier support: there is a workaround to fix this issue. Please follow the steps below:

1. IMPORTANT: Please backup your database and website before proceeding

2. Add the PHP code to the file functions.php in your theme/child theme folder:

add_filter( 'wcml_multi_currency_ajax_actions', 'add_action_to_multi_currency_ajax', 10, 1 );
function add_action_to_multi_currency_ajax( $ajax_actions ) {
    $ajax_actions[] = 'elementor_menu_cart_fragments'; // Add a AJAX action to the array
    return $ajax_actions;
}

Save changes and check the issue again.

Refer documentation https://wpml.org/wcml-hook/wcml_multi_currency_ajax_actions/

Look forward to your reply.
Thanks

April 25, 2023 at 7:28 am #13531163

blazejS-3

Thank you for your reply I will still check it acoustically I reversed the elementor 3 versions back and everything with the price works I think o is rather a problem on the side of the elementor plug although their supoport completely did not help me.