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

Currency update time setting for twice a day or daily updates

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

Hello,

I need to set the currency update time when it is set to daily. I see that when I change something on the site such as a restore, the update time change. I need to be able to set a time when that happens consistently based on GMT or our local time.  Is there a setting for that or some code to do that?

 

Hello

You  can  use  an external   cron.

To   update   rate:  do_action('woocs_update_rates_wpcron')

OR

global $WOOCS;

$WOOCS->rate_auto_update();

Thank you Pablo, I will try that.

Hello

Welcome;)

Hi Pablo,

I created a php file where I put the do_action('woocs_update_rates_wpcron') code in and getting the below error when running it.

Fatal error: Uncaught Error: Call to undefined function do_action()

I created a separate directory for this code so I can target the cronjob to the location and the file. Is there a specific place this code should be entered?

Hello

Please  read  this  - https://developer.wordpress.org/reference/functions/do_action/

This should be in wordpress, better in the wp-content folder

Hi Pablo,

I implemented the code and it seems to run without error but I cannot see the the rate changes in the backend at the WOOCS Currency Options.

Just to test, I manually clicked on a currency update button next to a currency and that currency  updated to a new rate value. Then I noticed that when I go to other places on the backend, like edit a page and go back to the Currency Options it reverted back to the previous currency value, changing back to the previous value that was there before the forced updated. I did a browser page reload and it did not make a difference.

This way at the moment I do not know if the code I implemented works or not because I cannot get Woocs to keep its own currency update that is done manually with the update button next to it.

I recorded it so you can see what I mean.

Currency rate auto update is set to 'daily' in case that has something to do with this.

Hello

Sorry, I do not see your video. Try using video/image transfer services by links. Example: Clip2net

The code I gave you does the full job and saves it

 

Hi Pablo,

Sorry about that, I did not realize that Jing is still using Flash for the video. Here is another https://www.screencast.com/t/8c5vuoiHOI1

Looking at the prices after the forced update for the particular currency does not reflect that update on the front end prices so it looks like it updates and then resets to the last scheduled updated price.

Regarding the code

global $WOOCS;
$WOOCS->rate_auto_update();

I am getting this message when running it manually

Fatal error: Uncaught Error: Call to a member function rate_auto_update() on null in .../public_html/wp-content/WOOCS_update.php

Hello

Your  video - Of course, if you click this button to update the rate, you should click the button to save the result! This is not related to the function that I gave you

Uncaught Error: Call to a member function rate_auto_update() on null in .../public_html/wp-content/WOOCS_update.php  - This error text explains everything.

global $WOOCS;  - This variable is out of scope.

Try to add somethings like this to functions.php

add_action('wp_header', function(){

if(isset($_GET['woocs_skey']) AND  $_GET['woocs_skey']=="add_your_secret_key"){

global $WOOCS;
$WOOCS->rate_auto_update();

}

});

AND  to  update  currency  use  this  link: https://your_site.com?woocs_skey=add_your_secret_key

He Pablo,

I know that the video was not related but I could not get the currency change to stay, forgetting that I actually need to save it.

Regarding the code you gave me, I implemented it in the functions.php in the child theme, see the private data for this topic where I posted it.

I run link in the the browser's address bar and there was no currency update on the site but the currency rates were actually newer as I checked it manually on the backend.

I also run the url with a cronjob and originally planned, see command used in the private data area, and that did not seem to do anything apart from getting an cronjob email with a lot of code in it. I know that I can prevent the email sending but was not expecting that huge amount of code to be included.

What am I doing wrong when I followed your instructions?

 

Hello

Sorry! That's my fault!

Please  use  hook "wp_head" -  https://c2n.me/45EXIMd.png

Hi Pablo,

Thank you, that helped. It is working now.

In the php I wrote some code to email me the updated currencies and what I found was interesting. The USD would not match with the one that was updated via the cronjob and the one showing in the backend of the woocs. See image https://www.screencast.com/t/vv9L0Q4k

I clicked that refresh button next to the rate several times but it would only show the rate you see in the image but when I forced a cronjob update by updating the cronjob time it came back with the same USD: 0.7082051...... instead of the USD: 0.6842..... value. The interesting thing is that the rest of the rates were identical to the email and the WOOCS backend rates displayed, as you can see.

here is the message part of the php email and I do not think I messed up the USD rate part of the code.

$message ="Currency update INT Site\r\nServer UTC Time:".$date_time."\r\nBrisbane Conversion Time:".$converted_date."\r\n\r\nUSD:". $currencies['USD']['rate']."\r\nCAD:".$currencies['CAD']['rate']."\r\nGBP:".$currencies['GBP']['rate']."\r\nNZD:".$currencies['NZD']['rate']."\r\nEUR:".$currencies['EUR']['rate']."\r\nHKD:".$currencies['HKD']['rate']."\r\nTRY:".$currencies['TRY']['rate']."\r\nZAR:".$currencies['ZAR']['rate']."\r\nSGD:".$currencies['SGD']['rate']."\r\nINR:".$currencies['INR']['rate'];

I even did the CTRL+F5 browser page refresh but did not make a difference.

What do you think causing the discrepancy between the cronjob and the WP backend prices?

 

Hello

Try to delete this code - https://c2n.me/45H6btN.png - and write it again manually (without spaces). Do  test  please

Hi Pablo,

I deleted it and re-typed it and there is no difference. I even deleted the currency and added it again and the same thing has happened. I also deleted and re-typed the USD text in the php and no difference. This is a bit strange behavior.

You can check out the conversion for the USD but seems to be fine, see image https://www.screencast.com/t/W2J6lw0c

All prices have a 3.5% surcharge after the conversion which is covering the bank conversion costs. Only AUD does not have the surcharge because that is the base currency and in the normal set price. So if you check then convert from AUD price plus the 3.5% and that is what you should see in the front end.

 

I forgot to include the link where the best to see all the prices on the front end https://barnaclerid.com/catalogue/

Hello

Please  drop  me  wp-admin+FTP  access  I will  check  it

All login is in the private data area. The php code is under the Snippets plugin and the snippet is called 'WOOCS Currency Updater with cronjob'

Hi Pablo,

Did you find anything? It is still happening. The USD rate has changed now a bit in the PHP email but still different to the one in WOOCS backend.

Hello

Please  drop  me  wp-admin  access.

Check  your  link  with  key -"test"

12