Content of the page

woocs_currency_data_manipulation

Content of the article

This hook uses in public function get_currencies of the plugin:

public function get_currencies()
{

    $default = array(
        'USD' => array(
            'name' => 'USD',
            'rate' => 1,
            'symbol' => '$',
            'position' => 'right',
            'is_etalon' => 1,
            'description' => 'USA dollar',
            'hide_cents' => 0,
            'flag' => '',
        ),
        'EUR' => array(
            'name' => 'EUR',
            'rate' => 0.89,
            'symbol' => '€',
            'position' => 'left_space',
            'is_etalon' => 0,
            'description' => 'Europian Euro',
            'hide_cents' => 0,
            'flag' => '',
        )
    );

    $currencies = get_option('woocs', $default);
    $currencies = apply_filters('woocs_currency_data_manipulation', $currencies);

    /*
      //http://currency-switcher.com/how-to-manipulate-with-currencies-rates/
      foreach ($currencies as $key => $value)
      {
      if($key == 'EUR'){
      $currencies[$key]['rate']=$currencies[$key]['rate']+0.025;
      break;
      }
      }
     */

    if (empty($currencies) OR ! is_array($currencies))
    {
        $currencies = $default;
    }


    return $currencies;
}

So you can use it for any manipulations with the currencies data.

Example:

add_filter('woocs_currency_data_manipulation', 'my_woocs_currency_data_manipulation', 1, 1);

function my_woocs_currency_data_manipulation($currencies)
{
    foreach ($currencies as $key => $value)
    {
        if ($key == 'USD')
        {
            $currencies[$key]['rate'] = $value['rate'] + 0.10;
            break;
        }
    }
    return $currencies;
}