• emielm

    (@emielm)


    Hello,

    I am trying to automatically update the WCML currency rates using this code in functions.php:

    function my_wp_currencies_filter( $rates_array ) {
        foreach ($rates_array as $key => $value) {
            $rates_array[$key] = 0.5;
        }
        return $rates_array;
    }
    add_filter( 'wcml_exchange_rates', 'my_wp_currencies_filter');

    I also tried this code:

    function my_wp_currencies_filter( $rates_array ) {
         var_dump( $rates_array );
         $wp_curr_rates = get_exchange_rates();
         var_dump( $wp_curr_rates);
         return $rates_array;
     }
    add_filter( 'wcml_exchange_rates', 'my_wp_currencies_filter');

    Unfortunately, on the WCML multi-currency settings in the wp backend, the rates are not updated. What is the proper way to make WP currencies update the WCML exchange rates?

    PS: Just to be clear: I got an API code set in the WP Currencies settings of course 🙂

    Thanks for any reply in advance.

    https://wordpress.org/plugins/wp-currencies/

Viewing 1 replies (of 1 total)
  • Plugin Author Fulvio Notarstefano

    (@nekojira)

    At some point I did have WCML integration semi-built in but I removed it as it wasn’t very reliable in how WCML worked. I think for the same error you encountered.

    You would have to update the array that WCML uses (a wp_option if I’m not mistaken) and replace the exchange rates with the new ones.

    You could run this periodically in a WordPress cron event or hook into an existing one, perhaps those used by WP Currencies.

    You could also WPML/WCML forums for more pointers.

    Cheers

Viewing 1 replies (of 1 total)
  • The topic ‘Automatically update WCML currency rates’ is closed to new replies.