• Resolved loic45

    (@loic45)


    Hello,

    I’m taking the liberty of contacting you today, as I’ve been experiencing a problem for several weeks on a customer’s site (https://www.maison-alcee.com/).
    This site uses several extensions, including WooCommerce Multilingual & Multicurrency with WPML and NitroPack. The aim is to display, for example, the price of the Persée Azur (https://www.maison-alcee.com/produit/persee/#azur) at €7,500 before tax for users in France, and at $8,900 before tax for users in the United States.

    The problem is as follows:
    When my VPN is deactivated and I’m in France, the price is displayed correctly in euros.
    However, when I activate the VPN to simulate a connection from the USA, the amount is sometimes displayed correctly ($8,900 excluding taxes), but most of the time it remains displayed in euros (€7,500 excluding taxes).

    I found a solution here: https://wpml.org/forums/topic/nitropack-and-multi-currency/
    So I added the following code to the functions.php file of my WordPress theme:

    function wcml_set_custom_currency_cookie( $currency = false ) {
    if ( is_admin() && !( defined('DOING_AJAX') && DOING_AJAX ) )
    return;
    if ( !empty( $currency ) ) {
    setcookie('wcml_custom_currency_cookie', $currency, time() + 60*60*24*7, '/');
    return;
    }
    if ( empty( $_COOKIE['wcml_custom_currency_cookie'] ) && function_exists( 'get_woocommerce_currency' ) ) {
    setcookie('wcml_custom_currency_cookie', get_woocommerce_currency(), time() + 60*60*24*7, '/');
    }
    }
    add_action('wcml_switch_currency', 'wcml_set_custom_currency_cookie');
    add_action('init', 'wcml_set_custom_currency_cookie');

    I’ve also added wcml_custom_currency_cookie (https://ibb.co/vV9Zvkk) to the NitroPack settings (Cache Settings > Cache).
    Unfortunately, the problem persists.

    For the record, I’m using a VPN for my tests.

    Would you have any suggestions or avenues to explore to solve this problem?

    Thanks in advance,
    Lo?c V.

    • This topic was modified 2 months, 2 weeks ago by loic45.

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support Andrés Cifuentes

    (@andrescifuentesr)

    Hello @loic45,

    You can try a using a filter like?wcml_user_store_strategy, in that way you can set a different storage strategy.

    Let me know if it helps,
    Andrés

    Thread Starter loic45

    (@loic45)

    Hello,

    Thanks for your feedback.

    I don’t understand how using a filter could solve the problem as I’ve already implemented this piece of code (without success):

    function wcml_set_custom_currency_cookie( $currency = false ) {
    if ( is_admin() && !( defined('DOING_AJAX') && DOING_AJAX ) )
    return;
    if ( !empty( $currency ) ) {
    setcookie('wcml_custom_currency_cookie', $currency, time() + 60*60*24*7, '/');
    return;
    }
    if ( empty( $_COOKIE['wcml_custom_currency_cookie'] ) && function_exists( 'get_woocommerce_currency' ) ) {
    setcookie('wcml_custom_currency_cookie', get_woocommerce_currency(), time() + 60*60*24*7, '/');
    }
    }
    add_action('wcml_switch_currency', 'wcml_set_custom_currency_cookie');
    add_action('init', 'wcml_set_custom_currency_cookie');

    Translated with DeepL.com (free version)

    This method creates the cookie.

    I’m in touch with Nitropack technical support (because I think it’s a compatibility problem between the two extensions) and here’s their feedback:

    Hello,
    Thank you for your patience!
    It seems that the currency switch is not affected in any way from JavaScript which leads us to believe that the currency is switched based on PHP functions…
    Could you please confirm if that is the case? If the currency plugin uses PHP to serve the currency based on IP location, NitroPack would not be able to detect those changes and would serve the initial state of the page.
    Using a solution that relies on JavaScript would allow NitroPack to detect changes in the currency based on location, and the proper currency will be served.
    We can suggest a Multicurrency plugin, such as the one from CURCY, since the plugin has built-in settings for caching compatibility.

    Can you tell me if the currency change is affected by JavaScript or if it’s based on PHP functions?

    Thanks in advance.
    Lo?c V.

    Plugin Support Andrés Cifuentes

    (@andrescifuentesr)

    Hello,

    It is based on PHP, we re-use WooCommerce’s geolocation:
    https://woocommerce.com/document/maxmind-geolocation-integration/

    You can check these files:
    /woocommerce-multilingual/classes/multi-currency/geolocation/Geolocation.php
    /woocommerce-multilingual/classes/multi-currency/geolocation/GeolocationBackendHooks.php
    /woocommerce-multilingual/classes/multi-currency/geolocation/GeolocationFrontendHooks.php

    It could be also helpful if you install NitroPack in the following Sandbox, in that way we will be able to replicate the issue and investigate further.

    If this is not possible and as you are in contact with NitroPack team, you can propose them to join our Go-Global program and interact directly with our development team.

    Regard

    Thread Starter loic45

    (@loic45)

    Bonjour,

    J’ai transmis votre réponse à NitroPack.
    Malheureusement, ils ne pourront rien faire pour corriger le problème et m’ont redirigé vers un autre plugin.

    Merci en tout cas pour votre aide.

    Plugin Support Andrés Cifuentes

    (@andrescifuentesr)

    Thank you for getting back to us and reporting this issue. We are in contact now with NitroPack team and we are looking forward for working together aiming a better integration between both plugins in a future.

    Merci beaucoup ! ??

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.