PluginUs.Net - Business Tools for WooCommerce and WordPress

[realize your idea - make your dreams come true]

Support Forum

You need to log-in to create request (topic) to the support

Issue with LiteSpeed Cache

The support doesn work on Saturdays and Sundays, so some Friday requests can be answered on Monday. If you have problems with registration ask help on contact us page please
If you not got email within 24~36 business hours, firstly check your spam box, and if no any email from the support there - back to the forum and read answer here. DO NOT ANSWER ON EMAILS [noreply@pluginus.net] FROM THE FORUM!! Emails are just for your info, all answers should be published only here.
The support doesn work on Saturdays and Sundays, so some Friday requests can be answered on Monday.
12

Hi! I've installed the plugin with LiteSpeed Cache plugin. Then, maybe cookies are causing problems with my geoip feature, because when a enabled it (cache plugin) the wrong currency is displayed.

Could you help me to solve it? Maybe adding exclutions to the currency cookies or something like that to my my caching plugin?

Thanks!

Hello

Please  read  this - https://currency-switcher.com/woocs-labs

Hi Pablo, thanks for your answer!

I've look up that link but this plugin isn't in that list. On the other hand, I don't knlow if you need that I use [FOX LABS] tag?

Please let me know if there is somthing I understood badly.

Thanks!

Hello

Sorry!  I added  wrong  link

Please  read this - https://currency-switcher.com/using-geolocation-causes-problems-doesnt-seem-to-work-for-me

What  plugin version number  are you using?

Hello Pablo! Thanks.

I readed that. I think the problem is right there. I've a custom code that adds the currency parameter to my URL. But when I enabled the"Geolocate (with page catching support)" the parameter of geolocalization is added to my URL and erase my currency parameter. My code is this:

function agregar_moneda_a_url() {
global $WOOCS;
$current_url ="http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
$parsed_url = parse_url( $current_url );

if ( isset( $parsed_url['query'] ) && !empty( $parsed_url['query'] ) ) {
return; // La URL ya tiene parámetros, no se hace nada
}

if ( is_page( 'precios' ) ) {
$moneda = $WOOCS->current_currency;
$new_url = add_query_arg( 'currency', $moneda, $current_url );
wp_redirect( $new_url );
exit;
}
}
add_action( 'template_redirect', 'agregar_moneda_a_url' );

Could you help me with it?

I think the problem with geolocalization issue will solved if I enable that option, but I need the currency parameter on my URL either.

Thanks in advance!

Hello

the parameter of geolocalization is added to my URL and erase my currency parameter.  - What is the parameter? My plugin doesn't add any parameters other than"currency"

Hi Pablo!

I put the code that I detailed in the previous message so that it adds the currency to the URL of the"Prices" page. That for one thing. On the other hand, when I activate the"Geolocate (with page catching support)", Woocommerce adds a parameter of this type to my URL:"?v=5b61a1b298a0". So I overwrite my currency parameter.

My understanding is that what I should do is have my code run after Woocommerce adds the geolocation parameter and adds it. But I don't know how. I will investigate.

Thanks!

Hello

yes this is incompatibility of your custom code with woocommerce

Describe why you need to add a parameter to the URL, maybe there is another way?

Hi Pablo!

Yes of course.

In fact I have disabled the geolocation compatible with caching (I just left the geolocation) and the caching plugin and yet I still have problems with it recognizing the correct currency.

I put you in context. I have installed a plugin that is a budgeter. Unfortunately it is not multicurrency, therefore I had to create two instances of the budgeter: one for Argentine pesos and another for dollars. These two instances are loaded on the same page,"/prices/", and from the Divi Builder create two code modules that display according to a conditional: if the"ARS" parameter of currency exists in the URL, display the module that has the shortcode of the budget in pesos; instead, if there is"USD" as a currency parameter in the URL, then hide the other one and load the budgeter in dollars.

In the WOOCS module I have geolocation activated and it takes ARS only for Argentina, for the rest of the countries it takes dollars.

I copied the link of my page on private to you.

I would appreciate your help!

Thanks in advance!

 

hello

You can  try  to  put "currency" in wp_head

an example:

add_action('wp_head', function(){

if(class_exists('WOOCS')  &&  is_page( 'precios' ) ) {

global $WOOCS;

$_GET['currency'] = $WOOCS->current_currency;

}

});

Hi Pablo!

I've used that code and issue is the same. It seems to works sometimes, but sometimes not. It's a big problem because users get his budgets in a wrong currency.

WOOCS uses any cookie that I could use to my conditions? Or what could be causing that when entering from different locations the cookie does not finish deleting and then the next user does not end up updating the geolocation?

Could I copy my functions.php code to you? There you can find something in the code that interferes with the correct functioning of the geolocation that I am not finding.

Thanks in advance!

 

On the other hand, I've configured now the currency switcher in that page temporally and allways shows as selected option ARS even though the currency that the woocs variable is taking is dollars. This generates confusion, so even if you have set the currency exchanger regardless of geolocation, users who want to budget in pesos proceed to load the form and at the end it returns the values in dollars.

 

Thanks!!

Hello

This plugin does not use cookies

To  get  current  currency:

php:  https://currency-switcher.com/function/woocs-current_currency

js: variable woocs_current_currency

 

Hi, Pablo! Thanks for your answer.

I have the Divi template installed and it allows me to use conditions to show one or another module if they are met. But I think there is some conflict somewhere because sometimes it works well and sometimes it doesn't. As if the geolocation does not work correctly. And sometimes the"current_currency" is one (since I add the corresponding parameter to the URL) and the currency switcher shows the other.

In the console I get the following errors related to the plugin:

Uncaught TypeError: Cannot read properties of undefined (reading 'Component')
at 16 (price-filter-frontend.js?ver=1.4.0:828:27)
at r (price-filter-frontend.js?ver=1.4.0:12:21)
at 51 (price-filter-frontend.js?ver=1.4.0:1515:17)
at r (price-filter-frontend.js?ver=1.4.0:12:21)
at 244 (price-filter-frontend.js?ver=1.4.0:908:17)
at r (price-filter-frontend.js?ver=1.4.0:12:21)
at 215 (price-filter-frontend.js?ver=1.4.0:901:21)
at r (price-filter-frontend.js?ver=1.4.0:12:21)
at price-filter-frontend.js?ver=1.4.0:46:18
at price-filter-frontend.js?ver=1.4.0:47:2

Maybe these errors are breaking the code and do not allow the correct functioning of the rest?

Thanks in advance!

Hello

Try  in file  - wp-content\plugins\woocommerce-currency-switcher\classes\woocs.php  - delete/comment  this  line - https://share.pluginus.net/image/i20230626114212.png

Hi Pablo! Thanks! The error message dissapear =)

 

But I'm still having problems with geolocalization =(

This is the code I have installed on my site to add the currency parameter:

function agregar_moneda_a_url() {
global $WOOCS;
$current_url ="http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
$parsed_url = parse_url($current_url);
if (isset($parsed_url['query']) && !empty($parsed_url['query'])) {
$params = [];
parse_str($parsed_url['query'], $params);
if (isset($params['currency'])) {
return; // El parámetro"currency" ya está presente en la URL, no se hace nada
}
}
if (is_page('precios')) {
$moneda = $WOOCS->current_currency;
$new_url = add_query_arg('currency', $moneda, $current_url);
wp_redirect($new_url);
exit;
}
}
add_action('template_redirect', 'agregar_moneda_a_url');
As you can see, the URL takes the value of currency configured as initial in the plugin options, not the one it should according to the geolocation. However, the currency exchanger is taking the value of currency according to the geolocation. I understand that I am close to the solution, but I must be loading the code at the wrong time, right? If it loaded the code at the same time or after when your plugin takes the geolocation value, then it should take the correct value from WOOCS.

If you could guide me with this I would appreciate it a lot!

Thanks!

Other thing. I should copy this file:"wp-content\plugins\woocommerce-currency-switcher\classes\woocs.php" on"wp-content\themes\my-theme\plugins\woocommerce-currency-switcher\classes\woocs.php" right? So that I don't get overwritten in future updates.

 

Thanks!

Hello

You can try  this  code - https://currency-switcher.com/function/woocs-get_currency_by_country

So that I don't get overwritten in future updates. - This will be  included  in the  next update

Hello Pablo!

I've tried that code but didn't work. The currency param appear empty on my URL. This is the code I've used:

function agregar_moneda_a_url() {
global $WOOCS;
$current_url ="http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
$parsed_url = parse_url($current_url);
if (isset($parsed_url['query']) && !empty($parsed_url['query'])) {
$params = [];
parse_str($parsed_url['query'], $params);
if (isset($params['currency'])) {
return; // El parámetro"currency" ya está presente en la URL, no se hace nada
}
}
if (is_page('precios')) {
$customer_country = $WOOCS->storage->get_val('woocs_user_country');
$moneda = $WOOCS->get_currency_by_country($customer_country);
$new_url = add_query_arg('currency', $moneda, $current_url);
wp_redirect($new_url);
exit;
}
}
add_action('template_redirect', 'agregar_moneda_a_url');

 

Now, I'm using this code:
function agregar_moneda_a_url() {
  global $WOOCS;
  $current_url ="http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
  $parsed_url = parse_url($current_url);
  if (isset($parsed_url['query']) && !empty($parsed_url['query'])) {
    $params = [];
    parse_str($parsed_url['query'], $params);
    if (isset($params['currency'])) {
      return; // El parámetro"currency" ya está presente en la URL, no se hace nada
    }
}
  if (is_page('precios')) {
    $moneda = $WOOCS->current_currency;
    $new_url = add_query_arg('currency', $moneda, $current_url);
    wp_redirect($new_url);
    exit;
  }
}
add_action('template_redirect', 'agregar_moneda_a_url');
But problem is that the page takes the"Initial currency" at first load. Then, if I click on option"Precios" of page menu, there it load the correct currency. Something it's wrong when the code reads the WOOCS currency at first. But I don't know where the error is =(
12