Change exchange rate by code to integrate with WCFM plugin
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 Ruth on March 16, 2022, 22:00Hello,
I am working on an interface to update the exchange rate manually, but through a view within the WCFM plugin, for this I am using the hook woocs_currency_data_manipulation, the problem is that the new value of the rate is not saved.
I have a template wcfm-views-rate.php and a functions file wcfm-custom-menus-functions.php.
The template code to display the currency table and update button is as follows:(wcfm-views-rate.php)
global $WOOCS;
$wcfico_var_currencies=$WOOCS->get_currencies();
?>
<div class="scrollbar-external_wrapper">
<div class="scrollbar-external">
<div id="woocs-currencies-options">
<table class="woocs__table woocs__data-table">
<thead>
<tr>
<th><?php echo esc_html__('Basic', 'woocommerce-currency-switcher') ?></th>
<th><?php echo esc_html__('Move', 'woocommerce-currency-switcher') ?></th><th><span class="icon-flag" title="<?php echo esc_html__('Flag', 'woocommerce-currency-switcher') ?>">
<span class="fa-solid fa-flag"></span>
</span></th>
<th><span class="icon-money" title="<?php echo esc_html__('Currency', 'woocommerce-currency-switcher') ?>">
<span class="fa-solid fa-money-bill"></span>
</span></th>
<th><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 24 24"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10s10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8s8 3.59 8 8s-3.59 8-8 8zm.31-8.86c-1.77-.45-2.34-.94-2.34-1.67c0-.84.79-1.43 2.1-1.43c1.38 0 1.9.66 1.94 1.64h1.71c-.05-1.34-.87-2.57-2.49-2.97V5H10.9v1.69c-1.51.32-2.72 1.3-2.72 2.81c0 1.79 1.49 2.69 3.66 3.21c1.95.46 2.34 1.15 2.34 1.87c0 .53-.39 1.39-2.1 1.39c-1.6 0-2.23-.72-2.32-1.64H8.04c.1 1.7 1.36 2.66 2.86 2.97V19h2.34v-1.67c1.52-.29 2.72-1.16 2.73-2.77c-.01-2.2-1.9-2.96-3.66-3.42z" fill="currentColor"/></svg></th>
<th><?php echo esc_html__('Position', 'woocommerce-currency-switcher') ?></th>
<th><?php echo esc_html__('Rate + %', 'woocommerce-currency-switcher') ?></th>
<th class="woocs_align_left"><?php echo esc_html__('Decimal', 'woocommerce-currency-switcher') ?></th><th class="woocs_align_left"><?php echo esc_html__('Separators', 'woocommerce-currency-switcher') ?></th>
<th><?php echo esc_html__('Visible', 'woocommerce-currency-switcher') ?></th>
<th><?php echo esc_html__('Cents', 'woocommerce-currency-switcher') ?></th>
<th><?php echo esc_html__('Description', 'woocommerce-currency-switcher') ?></th>
</tr>
</thead>
<tbody id="woocs_list">
<?php
if (!empty($wcfico_var_currencies) AND is_array($wcfico_var_currencies)) {
foreach ($wcfico_var_currencies as $key => $currency) {
$var_msaje = print_currency($currency);
//var_dump($currency);
}
}
?>
</tbody>
</table>
</div>
</div>
</div>
<?php
print_msaje( $var_msaje );
?>the function to print the currencies is as follows:
(wcfm-custom-menus-functions.php)
/*--- Funciones Actualizar Tasa de Cambio ---*/
function print_currency($currency){
//var_dump($currency);$woocs_custom_menu_var_ind_msaje = 0;
echo ('
<tr class="woocs_custom_menu_tr">
<td class="woocs_custom_menu_td">
<input class="woocs_is_etalon" type="radio" ');
if ($currency['is_etalon']===1) {
echo('checked="checked"');
}
echo(' disabled title="Set etalon main currency. This should be the currency in which the price of goods exhibited!">
</td>
<td class="woocs_custom_menu_td">
<span class="woocs_custom_menu_td_text"><span class="fa-solid fa-sort"></span></span>
</td>
<td class="woocs_custom_menu_td">
<span class="woocs_custom_menu_td_text">
<img src="'.$currency['flag'].'" alt="Flag"></img></span>
</td>
<td class="woocs_custom_menu_td">
<span class="woocs_custom_menu_td_text">'.$currency['name'].'</span>
</td>
<td class="woocs_custom_menu_td">
<span class="woocs_custom_menu_td_text">'.$currency['symbol'].'</span>
</td>
<td class="woocs_custom_menu_td">
<span class="woocs_custom_menu_td_text">'.$currency['position'].'</span>
</td>
<td class="woocs_custom_menu_td">
');
if ($currency['name'] == 'VEN'){
echo ('
<form id="woocs_custom_menu_form_update_rate" method="POST" >
<div style="display: flex; flex-wrap: wrap; justify-content: stretch; align-content: space-between;">
<div style="width: 40%;">
<input type="number" id="woocs_custom_menu_rate_id_fidens" name="woocs_custom_menu_rate_fidens" step="0.0001" min="1" max="" value="'.$currency['rate'].'"></input>
</div>
<div style="width: 20%;">
<span class="woocs_custom_menu_td_text"> + </span>
</div>
<div style="width: 20%;">
<span class="woocs_custom_menu_td_text">
');
if ($currency['rate_plus'] === ''){
echo (' 0 ');
}else{
echo ( $currency['rate_plus']);
}
echo ('</span>
</div>
<div style="width: 20%;">
<button class="" type="submit" id="woocs_custom_menu_rate_button_id" name="woocs_custom_menu_rate_button" title="Press the button if you want to update currency rate!" style="white-space: nowrap;">
<i class="fa-solid fa-arrows-rotate"></i>
</button>
</div>
</div>
</form>
');
if( isset($_POST['woocs_custom_menu_rate_button'])){
if( ! empty( $_REQUEST['woocs_custom_menu_rate_fidens'] ) ) {
global $WOOCSadd_filter('woocs_currency_data_manipulation', 'woocs_custom_menu_update_rates', 1, 1);
$wcfico_var_currencies_show=$WOOCS->get_currencies();
foreach ($wcfico_var_currencies_show as $key => $value){
if ($key === 'VEN'){
break;
}
}if( $wcfico_var_currencies_show[$key]['rate'] === $_REQUEST['woocs_custom_menu_rate_fidens'] ){
$woocs_custom_menu_var_ind_msaje = 1;}else{
$woocs_custom_menu_var_ind_msaje = 2;}
}else{
$woocs_custom_menu_var_ind_msaje = 3;}
}
}else{
echo ('
<div style="display: flex; flex-wrap: wrap; justify-content: stretch; align-content: space-between;">
<div style="width: 40%;">
<span class="woocs_custom_menu_td_text">'.$currency['rate'].'</span>
</div>
<div style="width: 20%;">
<span class="woocs_custom_menu_td_text"> + </span>
</div>
<div style="width: 20%;">
<span class="woocs_custom_menu_td_text">
');
if ($currency['rate_plus'] === ''){
echo (' 0 ');
}else{
echo ( $currency['rate_plus']);
}
echo ('</span>
</div>
<div style="width: 20%;">
<button class="" style="white-space: nowrap;" disabled>
<i class="fa-solid fa-arrows-rotate"></i>
</button>
</div>
</div>
');
}
echo (' </div>
</td>
<td class="woocs_custom_menu_td">
<span class="woocs_custom_menu_td_text">'.$currency['decimals'].'</span>
</td>
<td class="woocs_custom_menu_td">
<span class="woocs_custom_menu_td_text">
' );
switch ($currency['separators']){
case ( 0 ):
echo ('10,000.00');
break;
case ( 1 ):
echo ('10.000,00');
break;
case ( 2 ):
echo ('10 000.00');
break;
case ( 3 ):
echo ('10 000,00');
break;
case ( 4 ):
echo ('10000.00');
break;
case ( 0 ):
echo ('10000,00');
break;
}
echo ('</span>
</td>
<td class="woocs_custom_menu_td">
<span class="woocs_custom_menu_td_text">
' );
if ($currency['hide_on_front']==0){
echo ('Si');
}else{
echo ('No');
}
echo ('</span>
</td>
<td class="woocs_custom_menu_td">
<span class="woocs_custom_menu_td_text">
' );
if ($currency['hide_cents']==0){
echo ('Mostrar');
}else{
echo ('No mostrar');
}
echo ('
</span>
</td>
<td class="woocs_custom_menu_td">
<span class="woocs_custom_menu_td_text">'.$currency['description'].'</span>
</td>
</tr>
' );
return $woocs_custom_menu_var_ind_msaje;
}/* Se activa con el Filtro woocs_currency_data_manipulation */
/* Puede actualizar los valores de las Monedas */
function woocs_custom_menu_update_rates( $woocs_custom_menu_currencies_ins ){
//$woocs_custom_menu_new_rate = $_REQUEST['woocs_custom_menu_rate_fidens'];
echo ('
<div class="woocs_custom_menu_msje">
<span class="">Nueva tasa (funcion del filtro): '.$_REQUEST['woocs_custom_menu_rate_fidens'].'
</span>
</div>
');foreach ($woocs_custom_menu_currencies_ins as $key => $value){
if ($key === 'VEN'){
$woocs_custom_menu_currencies_ins[$key]['rate'] = $_REQUEST['woocs_custom_menu_rate_fidens'];
echo ('
<div class="woocs_custom_menu_msje">
<span class="">Tasa asignada al arreglo de Currencys: '.$woocs_custom_menu_currencies_ins[$key]['rate'].'
</span>
</div>
');
break;
}
}
//var_dump($woocs_custom_menu_currencies_ins);
return $woocs_custom_menu_currencies_ins;
}/* Mostrar los mensajes de actualización debajo del contenido (tabla de monedas) */
function print_msaje( $var_msaje ){
global $WOOCS;
$wcfico_var_currencies_show=$WOOCS->get_currencies();foreach ($wcfico_var_currencies_show as $key => $value){
if ($key === 'VEN'){
break;
}
}echo ('<div class="woocs_custom_menu_msje">');
switch ($var_msaje){
case ( 1 ):
echo ('<span class="">La tasa de cambio ha sido actualizada</br>
Tasa tipeada: '.$_REQUEST['woocs_custom_menu_rate_fidens'].'</br>
Tasa en Array: '.$wcfico_var_currencies_show[$key]['rate'].'</br>
</span>
');
break;
case ( 2 ):
echo ('<span class="">La tasa de cambio NO se actualizó</br>
Tasa tipeada: '.$_REQUEST['woocs_custom_menu_rate_fidens'].'</br>
Tasa en Array: '.$wcfico_var_currencies_show[$key]['rate'].'</br>
</span>
');
break;
case ( 3 ):
echo ('<span class="">El input está vacío</span>
');
break;
}
echo ('</div>');
}This function for printing the currencies is the one who invokes the hook woocs_currency_data_manipulation, this call executes my function, and returns the array of currencies with the correct data, however, when re-querying the value of the rate for the updated currency, it has the same value ancient.
Could you please give me some suggestion about it?
I am using the PRO version of the plugin in its Version 2.3.7.1Thank you a lot for your support.
Hello,
I am working on an interface to update the exchange rate manually, but through a view within the WCFM plugin, for this I am using the hook woocs_currency_data_manipulation, the problem is that the new value of the rate is not saved.
I have a template wcfm-views-rate.php and a functions file wcfm-custom-menus-functions.php.
The template code to display the currency table and update button is as follows:
(wcfm-views-rate.php)
global $WOOCS;
$wcfico_var_currencies=$WOOCS->get_currencies();
?>
<div class="scrollbar-external_wrapper">
<div class="scrollbar-external">
<div id="woocs-currencies-options">
<table class="woocs__table woocs__data-table">
<thead>
<tr>
<th><?php echo esc_html__('Basic', 'woocommerce-currency-switcher') ?></th>
<th><?php echo esc_html__('Move', 'woocommerce-currency-switcher') ?></th>
<th><span class="icon-flag" title="<?php echo esc_html__('Flag', 'woocommerce-currency-switcher') ?>">
<span class="fa-solid fa-flag"></span>
</span></th>
<th><span class="icon-money" title="<?php echo esc_html__('Currency', 'woocommerce-currency-switcher') ?>">
<span class="fa-solid fa-money-bill"></span>
</span></th>
<th><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 24 24"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10s10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8s8 3.59 8 8s-3.59 8-8 8zm.31-8.86c-1.77-.45-2.34-.94-2.34-1.67c0-.84.79-1.43 2.1-1.43c1.38 0 1.9.66 1.94 1.64h1.71c-.05-1.34-.87-2.57-2.49-2.97V5H10.9v1.69c-1.51.32-2.72 1.3-2.72 2.81c0 1.79 1.49 2.69 3.66 3.21c1.95.46 2.34 1.15 2.34 1.87c0 .53-.39 1.39-2.1 1.39c-1.6 0-2.23-.72-2.32-1.64H8.04c.1 1.7 1.36 2.66 2.86 2.97V19h2.34v-1.67c1.52-.29 2.72-1.16 2.73-2.77c-.01-2.2-1.9-2.96-3.66-3.42z" fill="currentColor"/></svg></th>
<th><?php echo esc_html__('Position', 'woocommerce-currency-switcher') ?></th>
<th><?php echo esc_html__('Rate + %', 'woocommerce-currency-switcher') ?></th>
<th class="woocs_align_left"><?php echo esc_html__('Decimal', 'woocommerce-currency-switcher') ?></th>
<th class="woocs_align_left"><?php echo esc_html__('Separators', 'woocommerce-currency-switcher') ?></th>
<th><?php echo esc_html__('Visible', 'woocommerce-currency-switcher') ?></th>
<th><?php echo esc_html__('Cents', 'woocommerce-currency-switcher') ?></th>
<th><?php echo esc_html__('Description', 'woocommerce-currency-switcher') ?></th>
</tr>
</thead>
<tbody id="woocs_list">
<?php
if (!empty($wcfico_var_currencies) AND is_array($wcfico_var_currencies)) {
foreach ($wcfico_var_currencies as $key => $currency) {
$var_msaje = print_currency($currency);
//var_dump($currency);
}
}
?>
</tbody>
</table>
</div>
</div>
</div>
<?php
print_msaje( $var_msaje );
?>
the function to print the currencies is as follows:
(wcfm-custom-menus-functions.php)
/*--- Funciones Actualizar Tasa de Cambio ---*/
function print_currency($currency){
//var_dump($currency);
$woocs_custom_menu_var_ind_msaje = 0;
echo ('
<tr class="woocs_custom_menu_tr">
<td class="woocs_custom_menu_td">
<input class="woocs_is_etalon" type="radio" ');
if ($currency['is_etalon']===1) {
echo('checked="checked"');
}
echo(' disabled title="Set etalon main currency. This should be the currency in which the price of goods exhibited!">
</td>
<td class="woocs_custom_menu_td">
<span class="woocs_custom_menu_td_text"><span class="fa-solid fa-sort"></span></span>
</td>
<td class="woocs_custom_menu_td">
<span class="woocs_custom_menu_td_text">
<img src="'.$currency['flag'].'" alt="Flag"></img></span>
</td>
<td class="woocs_custom_menu_td">
<span class="woocs_custom_menu_td_text">'.$currency['name'].'</span>
</td>
<td class="woocs_custom_menu_td">
<span class="woocs_custom_menu_td_text">'.$currency['symbol'].'</span>
</td>
<td class="woocs_custom_menu_td">
<span class="woocs_custom_menu_td_text">'.$currency['position'].'</span>
</td>
<td class="woocs_custom_menu_td">
');
if ($currency['name'] == 'VEN'){
echo ('
<form id="woocs_custom_menu_form_update_rate" method="POST" >
<div style="display: flex; flex-wrap: wrap; justify-content: stretch; align-content: space-between;">
<div style="width: 40%;">
<input type="number" id="woocs_custom_menu_rate_id_fidens" name="woocs_custom_menu_rate_fidens" step="0.0001" min="1" max="" value="'.$currency['rate'].'"></input>
</div>
<div style="width: 20%;">
<span class="woocs_custom_menu_td_text"> + </span>
</div>
<div style="width: 20%;">
<span class="woocs_custom_menu_td_text">
');
if ($currency['rate_plus'] === ''){
echo (' 0 ');
}else{
echo ( $currency['rate_plus']);
}
echo ('</span>
</div>
<div style="width: 20%;">
<button class="" type="submit" id="woocs_custom_menu_rate_button_id" name="woocs_custom_menu_rate_button" title="Press the button if you want to update currency rate!" style="white-space: nowrap;">
<i class="fa-solid fa-arrows-rotate"></i>
</button>
</div>
</div>
</form>
');
if( isset($_POST['woocs_custom_menu_rate_button'])){
if( ! empty( $_REQUEST['woocs_custom_menu_rate_fidens'] ) ) {
global $WOOCS
add_filter('woocs_currency_data_manipulation', 'woocs_custom_menu_update_rates', 1, 1);
$wcfico_var_currencies_show=$WOOCS->get_currencies();
foreach ($wcfico_var_currencies_show as $key => $value){
if ($key === 'VEN'){
break;
}
}
if( $wcfico_var_currencies_show[$key]['rate'] === $_REQUEST['woocs_custom_menu_rate_fidens'] ){
$woocs_custom_menu_var_ind_msaje = 1;
}else{
$woocs_custom_menu_var_ind_msaje = 2;
}
}else{
$woocs_custom_menu_var_ind_msaje = 3;
}
}
}else{
echo ('
<div style="display: flex; flex-wrap: wrap; justify-content: stretch; align-content: space-between;">
<div style="width: 40%;">
<span class="woocs_custom_menu_td_text">'.$currency['rate'].'</span>
</div>
<div style="width: 20%;">
<span class="woocs_custom_menu_td_text"> + </span>
</div>
<div style="width: 20%;">
<span class="woocs_custom_menu_td_text">
');
if ($currency['rate_plus'] === ''){
echo (' 0 ');
}else{
echo ( $currency['rate_plus']);
}
echo ('</span>
</div>
<div style="width: 20%;">
<button class="" style="white-space: nowrap;" disabled>
<i class="fa-solid fa-arrows-rotate"></i>
</button>
</div>
</div>
');
}
echo (' </div>
</td>
<td class="woocs_custom_menu_td">
<span class="woocs_custom_menu_td_text">'.$currency['decimals'].'</span>
</td>
<td class="woocs_custom_menu_td">
<span class="woocs_custom_menu_td_text">
' );
switch ($currency['separators']){
case ( 0 ):
echo ('10,000.00');
break;
case ( 1 ):
echo ('10.000,00');
break;
case ( 2 ):
echo ('10 000.00');
break;
case ( 3 ):
echo ('10 000,00');
break;
case ( 4 ):
echo ('10000.00');
break;
case ( 0 ):
echo ('10000,00');
break;
}
echo ('</span>
</td>
<td class="woocs_custom_menu_td">
<span class="woocs_custom_menu_td_text">
' );
if ($currency['hide_on_front']==0){
echo ('Si');
}else{
echo ('No');
}
echo ('</span>
</td>
<td class="woocs_custom_menu_td">
<span class="woocs_custom_menu_td_text">
' );
if ($currency['hide_cents']==0){
echo ('Mostrar');
}else{
echo ('No mostrar');
}
echo ('
</span>
</td>
<td class="woocs_custom_menu_td">
<span class="woocs_custom_menu_td_text">'.$currency['description'].'</span>
</td>
</tr>
' );
return $woocs_custom_menu_var_ind_msaje;
}
/* Se activa con el Filtro woocs_currency_data_manipulation */
/* Puede actualizar los valores de las Monedas */
function woocs_custom_menu_update_rates( $woocs_custom_menu_currencies_ins ){
//$woocs_custom_menu_new_rate = $_REQUEST['woocs_custom_menu_rate_fidens'];
echo ('
<div class="woocs_custom_menu_msje">
<span class="">Nueva tasa (funcion del filtro): '.$_REQUEST['woocs_custom_menu_rate_fidens'].'
</span>
</div>
');
foreach ($woocs_custom_menu_currencies_ins as $key => $value){
if ($key === 'VEN'){
$woocs_custom_menu_currencies_ins[$key]['rate'] = $_REQUEST['woocs_custom_menu_rate_fidens'];
echo ('
<div class="woocs_custom_menu_msje">
<span class="">Tasa asignada al arreglo de Currencys: '.$woocs_custom_menu_currencies_ins[$key]['rate'].'
</span>
</div>
');
break;
}
}
//var_dump($woocs_custom_menu_currencies_ins);
return $woocs_custom_menu_currencies_ins;
}
/* Mostrar los mensajes de actualización debajo del contenido (tabla de monedas) */
function print_msaje( $var_msaje ){
global $WOOCS;
$wcfico_var_currencies_show=$WOOCS->get_currencies();
foreach ($wcfico_var_currencies_show as $key => $value){
if ($key === 'VEN'){
break;
}
}
echo ('<div class="woocs_custom_menu_msje">');
switch ($var_msaje){
case ( 1 ):
echo ('<span class="">La tasa de cambio ha sido actualizada</br>
Tasa tipeada: '.$_REQUEST['woocs_custom_menu_rate_fidens'].'</br>
Tasa en Array: '.$wcfico_var_currencies_show[$key]['rate'].'</br>
</span>
');
break;
case ( 2 ):
echo ('<span class="">La tasa de cambio NO se actualizó</br>
Tasa tipeada: '.$_REQUEST['woocs_custom_menu_rate_fidens'].'</br>
Tasa en Array: '.$wcfico_var_currencies_show[$key]['rate'].'</br>
</span>
');
break;
case ( 3 ):
echo ('<span class="">El input está vacío</span>
');
break;
}
echo ('</div>');
}
This function for printing the currencies is the one who invokes the hook woocs_currency_data_manipulation, this call executes my function, and returns the array of currencies with the correct data, however, when re-querying the value of the rate for the updated currency, it has the same value ancient.
Could you please give me some suggestion about it?
I am using the PRO version of the plugin in its Version 2.3.7.1
Thank you a lot for your support.
Quote from Pablo Borysenco on March 17, 2022, 11:59Hello
please paste your license key here - https://share.pluginus.net/image/i20210618130558.png -> https://share.pluginus.net/image/i20210618130614.png
unfortunately checking your custom code is not included in the support
I did not see in your code a function to save data
Hello
please paste your license key here - https://share.pluginus.net/image/i20210618130558.png -> https://share.pluginus.net/image/i20210618130614.png
unfortunately checking your custom code is not included in the support
I did not see in your code a function to save data
Quote from Ruth on March 17, 2022, 16:50Hello,
To save the value of the new rate, I am using the hook that is in the line:
add_filter('woocs_currency_data_manipulation', 'woocs_custom_menu_update_rates', 1, 1);But I'm not quite sure what this hook is used for or how I should use it.
I only need to update the rate of the local currency, so in the function print_currency($currency), although I show the complete table of available currencies, only a form is created in the row of the local currency that activates an input to receive the new value for rate field, when clicking the update button, this code is executed:
if( isset($_POST['woocs_custom_menu_rate_button'])){
if( ! empty( $_REQUEST['woocs_custom_menu_rate_fidens'] ) ) {
global $WOCSadd_filter('woocs_currency_data_manipulation', 'woocs_custom_menu_update_rates', 1, 1);
$wcfico_var_currencies_show=$WOCS->get_currencies();
foreach ($wcfico_var_currencies_show as $key => $value){
if ($key === 'COME'){
break;
}
}}
}I hope you could please explain to me how to use the woocs_currency_data_manipulation hook, perhaps with an example.
Or your opinion to know if for this case it seems better to use the hook:
woocs_add_custom_rate
or the function:
$WOCS->storage->set_val('woocs_current_currency','USD');or some other.
I thank you very much for your support regarding this issue, and please clarify a little the use of hooks.
Best regards!
Hello,
To save the value of the new rate, I am using the hook that is in the line:
add_filter('woocs_currency_data_manipulation', 'woocs_custom_menu_update_rates', 1, 1);
But I'm not quite sure what this hook is used for or how I should use it.
I only need to update the rate of the local currency, so in the function print_currency($currency), although I show the complete table of available currencies, only a form is created in the row of the local currency that activates an input to receive the new value for rate field, when clicking the update button, this code is executed:
if( isset($_POST['woocs_custom_menu_rate_button'])){
if( ! empty( $_REQUEST['woocs_custom_menu_rate_fidens'] ) ) {
global $WOCS
add_filter('woocs_currency_data_manipulation', 'woocs_custom_menu_update_rates', 1, 1);
$wcfico_var_currencies_show=$WOCS->get_currencies();
foreach ($wcfico_var_currencies_show as $key => $value){
if ($key === 'COME'){
break;
}
}
}
}
I hope you could please explain to me how to use the woocs_currency_data_manipulation hook, perhaps with an example.
Or your opinion to know if for this case it seems better to use the hook:
woocs_add_custom_rate
or the function:
$WOCS->storage->set_val('woocs_current_currency','USD');
or some other.
I thank you very much for your support regarding this issue, and please clarify a little the use of hooks.
Best regards!
Quote from Pablo Borysenco on March 18, 2022, 12:45hello
You should hire a developer
woocs_currency_data_manipulation - This hook only passes the data to work after it is retrieved from the database. with this hook you can change rates all the time, but you have to keep custom rates on your side
woocs_add_custom_rate - this hook only works when the rate is being updated by the aggregator
To update curencies use update_option('woocs', $currencies); - this should store such an array - https://share.pluginus.net/image/i20220318104513.png
hello
You should hire a developer
woocs_currency_data_manipulation - This hook only passes the data to work after it is retrieved from the database. with this hook you can change rates all the time, but you have to keep custom rates on your side
woocs_add_custom_rate - this hook only works when the rate is being updated by the aggregator
To update curencies use update_option('woocs', $currencies); - this should store such an array - https://share.pluginus.net/image/i20220318104513.png
Quote from Ruth on March 21, 2022, 15:50Hello!
With update_option('woocs', $currencies); it has worked perfectly for me.
Thank you a lot.
Kind regards!
Hello!
With update_option('woocs', $currencies); it has worked perfectly for me.
Thank you a lot.
Kind regards!
Quote from Pablo Borysenco on March 22, 2022, 12:11Hello
Welcome;)
Hello
Welcome;)