WPCS - WordPress Currency Switcher Professional

How to manipulate with currencies rates

Sometimes some customers need manipulation with currency rates, for example add to USD rate 10%. Every body has its own logic and Math. This article just show how to do this.

  • open your theme functions.php
  • on the same bottom of the file write next code:
    add_filter('wpcs_currency_data_manipulation', 'wpcs_currency_data_manipulation', 1, 1);
    
    function wpcs_currency_data_manipulation($currencies)
    {
        foreach ($currencies as $key => $value)
        {
            if ($key == 'USD')
            {
                $currencies[$key]['rate'] = $value['rate'] + 0.10*$value['rate'];//add 10%
                break;
            }
        }
        return $currencies;
    }