businessdad

Easy Digital Downloads Currency Switcher - Basic Integration

Jan 21st, 2016
112
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class SomeClass {
  2.   /**
  3.    * Basic integration with Easy Digital Downloads Currency Switcher, developed by Aelia
  4.    * (http://aelia.co). This method can be used by any 3rd party plugin to
  5.    * return prices converted to the active currency.
  6.    *
  7.    * @param double price The source price.
  8.    * @param string to_currency The target currency. If empty, the active currency
  9.    * will be taken.
  10.    * @param string from_currency The source currency. If empty, Easy Digital Downloads base
  11.    * currency will be taken.
  12.    * @return double The price converted from source to destination currency.
  13.    * @author Aelia <support@aelia.co>
  14.    * @link http://aelia.co
  15.    * @link https://aelia.co/shop/currency-switcher-for-easy-digital-downloads/
  16.    */
  17.   public static function get_price_in_currency($price, $to_currency = null, $from_currency = null) {
  18.     if(empty($from_currency)) {
  19.       global $edd_options;
  20.       $from_currency = $edd_options['currency'];
  21.     }
  22.     if(empty($to_currency)) {
  23.       $to_currency = edd_get_currency();
  24.     }
  25.     return apply_filters('edd_aelia_cs_convert', $price, $from_currency, $to_currency);
  26.   }
  27.  
  28.   public function test() {
  29.     $price = 123;
  30.     // Just call the get_price_in_currency() method, no further action required
  31.     return self::get_price_in_currency($price);
  32.   }
  33. }
RAW Paste Data