• Resolved vladseka

    (@vladseka)


    Hi there.

    I’m trying to get the currency exchange rate between USD and CAD by Ajax. The default currency is USD. What I’m looking to get is the current rate existing in the plugin.

    This is something can you help me, please?

    Thanks in advance!

    • This topic was modified 1 year ago by vladseka.

    The page I need help with: [log in to see the link]

Viewing 8 replies - 1 through 8 (of 8 total)
  • Julian Vu

    (@julianvu)

    Hi @vladseka

    Unfortunately, it is not possible to AJAX switch currency. The page need to be reloaded to change currency.

    vladseka

    (@vladseka)

    Hi, Julian, thanks for your reply.
    Looks like my question was not so clear.
    I need to get the currency rate value between USD and CAD which is currently set in the plugin. (for example, 1.303)

    vladseka

    (@vladseka)

    I’m not going to switch the currency, just need the exchange rate value by ajax.

    • This reply was modified 1 year ago by vladseka.
    vladseka

    (@vladseka)

    To make the question more clear, I need your help with the PHP code to get the plugin’s exchange rate data.

    Plugin Author thanhtd

    (@thanhtd)

    @vladseka You can use method get_exchange( $main_currency, $currency_code ) in file \woocommerce-multi-currency\includes\data.php

    vladseka

    (@vladseka)

    Hi @thanhtd, thank you for your help. 🙂

    As I understood, the function from USD to CAD is like this? get_exchange(‘USD’, ‘CAD’)

    And how can I call this function in the theme’s function.php file?

    vladseka

    (@vladseka)

    Hi, I’ve found the currency_rate value in the wp_option table, the option name is woo_multi_currency_params.

    I found that the currency_rate value is located here.
    s:13:"currency_rate";a:2:{i:0;s:1:"1";i:1;s:5:"1.303";}

    What I need to get is the value 1.303

    I tried below to response to the ajax.

    $rate_val = get_option('woo_multi_currency_params');
    echo $rate_val;

    But the console shows empty response.

    Is there anyway to get that value, please?

    Thanks!

    Plugin Author thanhtd

    (@thanhtd)

    You can try :

    $data     = new WOOMULTI_CURRENCY_Data();
    $get_rate = $data->get_exchange( 'USD', 'CAD' );
    echo '<pre>', print_r( $get_rate, true ), '</pre><hr>';
    • This reply was modified 1 year ago by thanhtd.
Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Get currency exchange rates data by Ajax’ is closed to new replies.