Auto update currency on cart
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 pleaseIf 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.
Quote from xpandeg on February 8, 2021, 12:44Hello, is it possible to force autoupdate currency in cart? I've trouble because my customer add to cart product formerly, but realize order now. Currency rate didn't update in cart. Can You help me?
Best.
Michał Sołtys
Hello, is it possible to force autoupdate currency in cart? I've trouble because my customer add to cart product formerly, but realize order now. Currency rate didn't update in cart. Can You help me?
Best.
Michał Sołtys
Quote from Pablo Borysenco on February 8, 2021, 13:44Hello Michał Sołtys
I'm not sure I understood you correctly.
Please describe it in more detail.
Items in the cart are always counted with current rates
Hello Michał Sołtys
I'm not sure I understood you correctly.
Please describe it in more detail.
Items in the cart are always counted with current rates
Quote from xpandeg on February 8, 2021, 14:52I am sorry Pablo.
I forgot to overwrite address to bank tables (from http://api.nbp.pl/api/exchangerates/tables/A "mid" to http://api.nbp.pl/api/exchangerates/tables/C "ask") after update the plugin.
My mistake.
Have we got a filter or hook to overwrite addresses (see above) from file woocs_after_33.php? To change default rate adresses to custom?
Best.
MS
I am sorry Pablo.
I forgot to overwrite address to bank tables (from http://api.nbp.pl/api/exchangerates/tables/A"mid" to http://api.nbp.pl/api/exchangerates/tables/C"ask") after update the plugin.
My mistake.
Have we got a filter or hook to overwrite addresses (see above) from file woocs_after_33.php? To change default rate adresses to custom?
Best.
MS
Quote from Pablo Borysenco on February 9, 2021, 10:30Hello
Please try to use this code(paste in functions.php)
add_filter('woocs_bank_polski_table', function($a){
return "C";
});
Hello
Please try to use this code(paste in functions.php)
add_filter('woocs_bank_polski_table', function($a){
return"C";
});
Quote from xpandeg on February 9, 2021, 12:35Thanks. Is it possible to change by filter "mid" to "ask" from this code:
if (!empty($currency_data[0])) { foreach ($currency_data[0]['rates'] as $c) { $rates[$c['code']] = floatval($c['mid']); } }It's important for me because in table "C" (http://api.nbp.pl/api/exchangerates/tables/C) doesn't exist "mid", but here is "bid" or "ask". Best.
Thanks. Is it possible to change by filter"mid" to"ask" from this code:
if (!empty($currency_data[0])) {
foreach ($currency_data[0]['rates'] as $c) {
$rates[$c['code']] = floatval($c['mid']);
}
}It's important for me because in table"C" (http://api.nbp.pl/api/exchangerates/tables/C) doesn't exist"mid", but here is"bid" or"ask". Best.
Quote from Pablo Borysenco on February 10, 2021, 10:35Hello
In this case please read - https://currency-switcher.com/how-to-add-its-own-custom-currency-aggregator/
Hello
In this case please read - https://currency-switcher.com/how-to-add-its-own-custom-currency-aggregator/
Quote from xpandeg on February 10, 2021, 17:06Thank You, i tried make some filter, but i did mistake. Plugin can't update rates.
My code is:add_action('woocs_announce_aggregator', function($aggregators) { $aggregators['nbp_table_c'] = 'NBP TABLE C'; return $aggregators; }); add_action('woocs_add_aggregator_processor', function($aggregator_key, $currency_name) { global $WOOCS; $request = []; //ratesapi.io as an example //see more examples in file \classes\woocs_after_33.php in public function get_rate() if ($aggregator_key === 'nbp_table_c') { $url = 'http://api.nbp.pl/api/exchangerates/tables/C'; //A,B if (function_exists('curl_init')) { $res = $WOOCS->file_get_contents_curl($url); } else { $res = file_get_contents($url); } $currency_data = json_decode($res, TRUE); $rates = array(); if (!empty($currency_data[0])) { foreach ($currency_data[0]['rates'] as $c) { $rates[$c['code']] = floatval($c['ask']); } } if (!$request) { $request = sprintf("no data for %s", $currency_name); } } return $request; }, 10, 2);
Thank You, i tried make some filter, but i did mistake. Plugin can't update rates.
My code is:
add_action('woocs_announce_aggregator', function($aggregators) {
$aggregators['nbp_table_c'] = 'NBP TABLE C';
return $aggregators;
});
add_action('woocs_add_aggregator_processor', function($aggregator_key, $currency_name) {
global $WOOCS;
$request = [];
//ratesapi.io as an example
//see more examples in file \classes\woocs_after_33.php in public function get_rate()
if ($aggregator_key === 'nbp_table_c') {
$url = 'http://api.nbp.pl/api/exchangerates/tables/C'; //A,B
if (function_exists('curl_init')) {
$res = $WOOCS->file_get_contents_curl($url);
} else {
$res = file_get_contents($url);
}
$currency_data = json_decode($res, TRUE);
$rates = array();
if (!empty($currency_data[0])) {
foreach ($currency_data[0]['rates'] as $c) {
$rates[$c['code']] = floatval($c['ask']);
}
}
if (!$request) {
$request = sprintf("no data for %s", $currency_name);
}
}
return $request;
}, 10, 2);Quote from Pablo Borysenco on February 11, 2021, 11:08Hello
it looks like this link returns XML - https://c2n.me/4aUqbmq.png
To get rates use - simplexml_load_string($res); - instead of - https://c2n.me/4aUqgOn.png
and $res->ExchangeRatesTable->Rates to get list of currencies
Hello
it looks like this link returns XML - https://c2n.me/4aUqbmq.png
To get rates use - simplexml_load_string($res); - instead of - https://c2n.me/4aUqgOn.png
and $res->ExchangeRatesTable->Rates to get list of currencies
Quote from xpandeg on February 11, 2021, 16:35I make this but something go wrong:
add_action('woocs_announce_aggregator', function($aggregators) { $aggregators['nbp_table_c'] = 'NBP TABLE C'; return $aggregators; }); add_action('woocs_add_aggregator_processor', function($aggregator_key, $currency_name) { global $WOOCS; $request = []; //ratesapi.io as an example //see more examples in file \classes\woocs_after_33.php in public function get_rate() if ($aggregator_key === 'nbp_table_c') { $url = 'http://api.nbp.pl/api/exchangerates/tables/C'; //A,B if (function_exists('curl_init')) { $res = $WOOCS->file_get_contents_curl($url); } else { $res = file_get_contents($url); } $currency_data = simplexml_load_string($res); $rates = array(); if (!empty($currency_data[0])) { foreach ($currency_data[0]['rates'] as $c) { $rates[$c['code']] = floatval($c['ask']); } } $request = isset($currency_data['ExchangeRatesTable'][$currency_name]) ? $currency_data['rates'][$currency_name] : 0; if (!$request) { $request = sprintf("no data for %s", $currency_name); } } return $request; }, 10, 2);
I make this but something go wrong:
add_action('woocs_announce_aggregator', function($aggregators) {
$aggregators['nbp_table_c'] = 'NBP TABLE C';
return $aggregators;
});
add_action('woocs_add_aggregator_processor', function($aggregator_key, $currency_name) {
global $WOOCS;
$request = [];
//ratesapi.io as an example
//see more examples in file \classes\woocs_after_33.php in public function get_rate()
if ($aggregator_key === 'nbp_table_c') {
$url = 'http://api.nbp.pl/api/exchangerates/tables/C'; //A,B
if (function_exists('curl_init')) {
$res = $WOOCS->file_get_contents_curl($url);
} else {
$res = file_get_contents($url);
}
$currency_data = simplexml_load_string($res);
$rates = array();
if (!empty($currency_data[0])) {
foreach ($currency_data[0]['rates'] as $c) {
$rates[$c['code']] = floatval($c['ask']);
}
}
$request = isset($currency_data['ExchangeRatesTable'][$currency_name]) ? $currency_data['rates'][$currency_name] : 0;
if (!$request) {
$request = sprintf("no data for %s", $currency_name);
}
}
return $request;
}, 10, 2);Quote from Pablo Borysenco on February 12, 2021, 12:01Hello
you did it wrong
you have to work with data as simpleXML object - https://c2n.me/4aVufuZ.png
Read this please - https://www.php.net/manual/en/book.simplexml.php
Hello
you did it wrong
you have to work with data as simpleXML object - https://c2n.me/4aVufuZ.png
Read this please - https://www.php.net/manual/en/book.simplexml.php