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: Compatibility, Go Global Application
This topic contains 19 replies, has 2 voices.
Last updated by Subash Chandra Poudel 1 year, 5 months ago.
Assisted by: Subash Chandra Poudel.
Author | Posts |
---|---|
July 10, 2023 at 11:37 am #13979817 | |
grzegorzK-16 |
Hi! I am using "Filter Everything" plugin to configure the filter in the store sidebar. My website is Polish-English. I have WPML and "WooCommerce Multilingual & Multicurrency" plugins installed. The website is configured in such a way that after switching to the Polish language, the products are displayed in the Polish currency. In the "Filter Everything" plugin, the price slider is configured as follows: I tested the plugin for the following Meta Keys: _regular_price and _price. In both cases, the maximum price in the slider does not change after changing the language. The "Filter Everything" support gave me a different Meta Key: _woocs_regular_price. But it doesn't work. What is the correct Meta Key? See appripiate screenshots… |
July 10, 2023 at 6:30 pm #14009003 | |
Subash Chandra Poudel |
Hi there, Please note "Filter Everything" plugin is not in our list of WPML Compatible Plugins ( https://wpml.org/plugin/ ), so there could be some issues. I also see the plugin claims to be WPML compatible in their page so please also report this issue to the Plugin provider. This does not means the plugin is incompatible with WPML though. To test the issue further lets setup the plugin on a minimal sandbox site and troubleshoot there. I have setup a sandbox site for you which you can login to using the next link: hidden link Can you please login to the sandbox site and do the following: - Setup WPML and WooCommerce ( WPML key will be provided while you set it up ) - Add the plugin and minimal numbers of products and settings so as to replicate the issue on the site. - Let me know the Page URLs where I can see the issue. Regards, |
July 11, 2023 at 11:50 am #14014121 | |
grzegorzK-16 |
Hi! I am aware that the "Filter everything" plugin is not in the https://wpml.org/plugin/ list. I'm testing it because all the plugins I found in this list don't work properly. Here is a list of these plugins: • "annasta Woocommerce Product Filters" - In this plugin, the minimum and maximum slider amounts are not calculated automatically. You have to enter it manually. So, I don't know why this plugin is recommended by WPML. • "Jetsmartfilters" (hidden link) - This plugin is paid. There is no free check for a month. So there is no way to test it. • "PWF – Products Filter for WooCommerce" - The same problem occurs here as in the "Filter everything" plugin. Changing the language does not change the maximum amount in the price slider. I don't know why this plugin is recommended by WPML if it works badly. • "searchandfiltter" (hidden link) - This plugin is paid. There is no free check for a month. So there is no way to test it. • "WooCommerce Product Filter" - I don't know why this plugin is included in this list since even WPML itself doesn't recommend it (see screenshot). • "YITH WooCommerce Ajax Product Filter" - In this plugin, the price slider is only available in the paid version and also without the possibility to test it for a month. If there is any other plugin that works fine, please let me know. Honestly, I'm very disappointed! WPML and WPML support is paid (quite a lot of money) and there isn't a single plugin recommended by WPML that works properly! It does not matter whether the prices are converted based on the exchange rate or whether the prices in the additional currency are entered manually. In both these cases, when changing the language, the amounts in the price slider do not change. In the next post, I will send information about the configured sandbox site. regards, |
July 11, 2023 at 12:25 pm #14014697 | |
grzegorzK-16 |
Hi! I have set up a sandbox page as follows: • Blocksy Theme - Cleanest setup just to have a sidebar on the store page. • Page is Polish - English. • "WooCommerce Multilingual & Multicurrency" is configured in such a way that after turning on the Polish language, product prices are displayed in Polish currency. For English, • I manually configured the exchange rate as follows: PLN 1 = USD 0.5. • I imported 5 test products. They all have the "Calculate prices in other currencies automatically" option enabled. • Polish product prices: PLN 10.00, PLN 20.00, PLN 30.00, PLN 40.00, PLN 50.00. • Prices in dollars: $5.00, $10.00, $15.00, $20.00, $25.00. For the sidebar filter, I used the "Filter everything" plugin. When the Polish language is turned on, the slider correctly displays the maximum price. After changing the language to English, the maximum amount in the slider should be 25. Unfortunately, 50 remains. Configuration of the "Filter everything" plugin: • I used _price Meta Key to configure the price slider. • I also tested _regular_price Meta Key. But unfortunately, it didn't change anything. • "Filter everything" plugin support told me the Meta Key: _woocs_regular_price, which also didn't work properly. Unfortunately, when asked again, they replied that they couldn't help me any more and that I should ask other supports about it. Please, what is the correct Meta Key? • Polish version store: hidden link You have a language switcher as well. regards, |
July 11, 2023 at 12:30 pm #14014781 | |
grzegorzK-16 |
You can test other plugins on sandbox site as well...:) |
July 13, 2023 at 5:15 pm #14035445 | |
Subash Chandra Poudel |
Hi Grzegorz, Thank you for your detailed message. For compatibility issue with other plugin if you could open a new ticket for the plugin that you need help with we can better help you there. Regarding the compatibility of Filter Everything plugin I have escalated the issue to our Compatibility team and I will send you an update here after our team makes preliminary checks and decide weather the plugin can be supported or a workaround can be provided. Also, in the mean time if you could please contact the plugin provider again and ask them to join our Go Global Program linked next it can make the problem solving faster, if the plugin provider agree to collaborate with us in fixing the issue. https://wpml.org/documentation/support/go-global-program/ Regards, |
July 17, 2023 at 2:31 pm #14050529 | |
grzegorzK-16 |
Hi Finally, I bought the "Filter Everything" plugin. Unfortunately, "Fitler Everything" support is not very willing to help 🙂 but I have some information from them. I'm not a PHP developer, but maybe together we can find a temporary workaround. Here's what I got from them and figured it out myself: In the wpc-third-party.php file of the Filer Everything plugin, there is code that adds compatibility of the price filter (slider) with the WOOCS and CURCY multi-currency plugins. This code starts with line 465. I think that based on this, your developers will be able to implement a snippet adding compatibility with "The WordPress Multilingual Plugin", which I will be able to add to the functions.php file. I don't know PHP, but according to my intuition, the wpc_set_num_shift and wpc_unset_num_shift hooks are crucial in this logic. The logic of such a snippet, it seems to me, should be as follows: How can I provide the wpc-third-party.php file or the function itself? Regards, |
July 18, 2023 at 6:29 am #14054561 | |
grzegorzK-16 |
The file I was talking about (wpc-third-party.php) is available in the free version of the Filter Everything plugin. Just download the entire plugin from https://wordpress.org/plugins/filter-everything/. |
July 18, 2023 at 11:01 am #14058491 | |
Subash Chandra Poudel |
Thank you for the updates Grzegorz! Our compatibility team were also looking into the same code in the mean time and they came up with the following code. Can you please insert the following code in your child theme functions.php file and see if it helps? // Fix for Filter Everything WCML multicurrency support compsupp-6872 add_action('init', 'flrt_add_wpml_currencies_support'); function flrt_add_wpml_currencies_support() { // Add this block for WPML if ( class_exists('SitePress') ) { // Converts values into selected currency. Visible in the range slider form add_filter( 'wpc_set_num_shift', 'flrt_set_wpml_shift', 10, 2 ); function flrt_set_wpml_shift( $value, $entity_name ) { if ( $entity_name === '_price' ) { $value = apply_filters('wcml_raw_price_amount', $value); } return $value; } // Converts values back to default currency for WP_Query add_filter( 'wpc_unset_num_shift', 'flrt_unset_wpml_shift', 10, 2 ); function flrt_unset_wpml_shift( $value, $entity_name ) { if ($entity_name === '_price') { $wpml_current_currency = apply_filters('wcml_price_currency', NULL); $wpml_exchange = apply_filters('wcml_raw_price_amount', 1, $wpml_current_currency); $value = $value / $wpml_exchange; } return $value; } } } I have already inserted it in the Sandbox site. Please let me know how it goes and before implementing it on your live site please make sure to completely backup the site to prevent any issues. Regards, |
July 19, 2023 at 8:55 am #14063777 | |
grzegorzK-16 |
Hi! Thank you very much for the provided snippet. It works, but only for prices automatically calculated upon exchange rate. But, as you remember I need the price slider to work correctly for prices manually added. I did the following test. I have enabled the "Set prices in other currencies manually" option in all my products. After switching the page to English, the maximum amount in the slider changed, but to the amount converted based on the exchange rate, and not to the maximum dollar price entered manually. Moreover, it is important to remember that it is never the case that all products have automatic conversion enabled, or that all products have manual additional currency amounts enabled. There may be a mixed situation. For some products, the option "Calculate prices in other currencies automatically" may be enabled, and for the other part, the option "Set prices in other currencies manually". In the meantime, I also tried to write my code. I wrote the function needed for the wpc_set_num_shift hook entirely differently. And to my amazement, the whole thing works the same as your snippet. I'm surprised because I'm not a PHP programmer and I was guided by my general IT experience. Below is my snippet. If the line in your code (apply_filters('wcml_raw_price_amount', $value)) or the function (convert_price_amount_by_currencies) in my code somehow would take into account the possibility of manually setting prices, then I think we will finally achieve our goal. It may be helpful to know that the manually entered price is stored for the _price_usd key. I really hope that now your specialists will find a solution to the problem 🙂 // Fix for Filter Everything WCML multicurrency support compsupp-6872 add_action('init', 'flrt_add_wpml_currencies_support'); function flrt_add_wpml_currencies_support() { // Add this block for WPML if ( class_exists('SitePress') ) { // Converts values into selected currency. Visible in the range slider form add_filter( 'wpc_set_num_shift', 'flrt_set_multiling_multicurr_shift', 10, 2 ); function flrt_set_multiling_multicurr_shift ( $value, $entity_name ) { global $woocommerce_wpml; if ( $entity_name === '_price' ) { if ( method_exists( 'woocommerce_wpml', 'get_multi_currency' ) ) { $multi_currency = $woocommerce_wpml->get_multi_currency(); // to jest WCML_Multi_Currency if ( ! method_exists( 'WCML_Multi_Currency', 'get_client_currency' ) || ! function_exists('wcml_get_woocommerce_currency_option' ) ) { return $value; } $default_currency = wcml_get_woocommerce_currency_option(); $current_currency = $multi_currency -> get_client_currency(); if ( $default_currency !== $current_currency && method_exists( 'WCML_Multi_Currency_Prices', 'convert_price_amount_by_currencies' ) ) { $WCML_Multi_Currency_Prices = new WCML_Multi_Currency_Prices( $multi_currency, $woocommerce_wpml->get_setting( 'currency_options' ) ); $value = $WCML_Multi_Currency_Prices -> convert_price_amount_by_currencies( $value, $default_currency, $current_currency ); } } } return $value; } // Converts values back to default currency for WP_Query add_filter( 'wpc_unset_num_shift', 'flrt_unset_wpml_shift', 10, 2 ); function flrt_unset_wpml_shift( $value, $entity_name ) { if ($entity_name === '_price' ) { $wpml_current_currency = apply_filters('wcml_price_currency', NULL); $wpml_exchange = apply_filters('wcml_raw_price_amount', 1, $wpml_current_currency); $value = $value / $wpml_exchange; } return $value; } } } |
July 19, 2023 at 11:13 am #14065611 | |
grzegorzK-16 |
I came up with another idea that seems to have solved my problem. Namely, I will have two Filter sets created, for example, PL Filter Set and EN Filter Set. In the first one, the Price Slider will have the "_price" Meta Key. And the other "_price_usd". Now the question remains how to make PL Filter Set displayed in the Polish store page, and EN Filter Set on the English-language store page. My guess is that something is needed here that replaces the Set Filter in the sidebar. The logic is something like this: ... some code ... $lang = apply_filters( 'wpml_current_language', null ); if($lang=='pl') { // Display: PL Filter Set } else { // Display: PL Filter Set } ... some code ... |
July 19, 2023 at 11:21 am #14065673 | |
grzegorzK-16 |
... some code ... $lang = apply_filters( 'wpml_current_language', null ); if($lang=='pl') { // Display: PL Filter Set } else { // Display: EN Filter Set } ... some code ... |
July 19, 2023 at 5:14 pm #14067951 | |
Subash Chandra Poudel |
Hi Grzegorz, Our second tier team shared a better code to what I shared in my previous reply ( https://wpml.org/forums/topic/filter-everything-plugin-issue/#post-14058491 ). // WPML workaround for compsupp-6872 if ( class_exists('SitePress') && class_exists('woocommerce_wpml') ) { // Converts values into selected currency. Visible in the range slider form add_filter( 'wpc_set_num_shift', 'flrt_set_wpml_shift', 10, 2 ); function flrt_set_wpml_shift( $value, $entity_name ) { if ( $entity_name === '_price' ) { $value = apply_filters('wcml_raw_price_amount', $value); } return $value; } // Converts values back to default currency for WP_Query add_filter( 'wpc_unset_num_shift', 'flrt_unset_wpml_shift', 10, 2 ); function flrt_unset_wpml_shift( $value, $entity_name ) { if ($entity_name === '_price') { global $woocommerce_wpml; $mc = $woocommerce_wpml->get_multi_currency(); $default_currency = wcml_get_woocommerce_currency_option(); $value = $mc->prices->unconvert_price_amount( $value, $default_currency ); } return $value; } } Please make use of this code instead and see if it helps. This is still not compatible with custom price though. So you can use the two different widgets for the languages with different settings. And you can following use the different Widgets per language as explained in the next document: Please let me know how it goes. If you could share your final setup/code it might help other users as well. Regards, |
July 20, 2023 at 6:18 pm #14074749 | |
grzegorzK-16 |
Hi! The last snippet you sent works, and as you wrote, it does not take into account prices entered manually. I'm afraid that using different widgets (different Filter Sets) for each language will not work. Even if it were possible to implement Filter Set with meta key _price for the Polish language, and Filter Set with meta key _price_usd for the English language, it probably won't work. This is due to the fact that the _price_usd key displays the value of the manually entered amount of the additional language only when the Polish language is turned on. After switching the page to English, the _price_usd key does not store any values. Please see attached images. In addition, the configuration of the Filer Everything plugin does not provide for the selection of a Filter Set in the widget. Instead, where a given Filter Set is to be displayed is configured in the settings of that Filter Set. (See attached images). The solution would be a function (for the hook 'wpc_set_num_shift') that takes into account the prices calculated based on the exchange rate and those entered manually. It may be that among the products in which the "Calculate prices in other currencies automatically" option is enabled, one product has the "Set prices in other currencies manually" option enabled and it is accidentally the highest price. That is the one that must be displayed in the slider. So still I am asking for help in this issue:) regards, |
July 21, 2023 at 8:05 am #14076755 | |
Subash Chandra Poudel |
Hi Grzegorz, Thank you for the updates. So did the use of different widget for different languages along with your idea at https://wpml.org/forums/topic/filter-everything-plugin-issue/#post-14065611 not work? I am checking with our team if expanding the code to support for custom price is possible. Which I think might take some time if possible at all. I will send you an update here as soon as we have an update. Regards, |