View difference between Paste ID: JWe5ZYfy and ASBhBJ0w
SHOW: | | - or go back to the newest paste.
1-
class Basic_CurrencySwitcher_Integration {
1+
class SomeClass {
2
  /**
3-
   * Basic integration with WooCommerce Currency Switcher, developed by Aelia
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-
   * Need a consultation? Find us on Codeable: https://aelia.co/hire_us
7+
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-
   * @param string from_currency The source currency. If empty, WooCommerce base
12+
13
   * @author Aelia <support@aelia.co>
14
   * @link http://aelia.co
15
   * @link https://aelia.co/shop/currency-switcher-for-easy-digital-downloads/
16-
   * @link https://aelia.co
16+
17
  public static function get_price_in_currency($price, $to_currency = null, $from_currency = null) {
18-
  protected function get_price_in_currency($price, $to_currency = null, $from_currency = null) {
18+
19-
    // If source currency is not specified, take the shop's base currency as a default
19+
      global $edd_options;
20
      $from_currency = $edd_options['currency'];
21-
      $from_currency = get_option('woocommerce_currency');
21+
22
    if(empty($to_currency)) {
23-
	// If target currency is not specified, take the active currency as a default.
23+
      $to_currency = edd_get_currency();
24-
    // The Currency Switcher sets this currency automatically, based on the context. Other
24+
25-
    // plugins can also override it, based on their own custom criteria, by implementing
25+
    return apply_filters('edd_aelia_cs_convert', $price, $from_currency, $to_currency);
26-
    // a filter for the "woocommerce_currency" hook. 
26+
27-
    //
27+
  
28-
    // For example, a subscription plugin may decide that the active currency is the one 
28+
  public function test() {
29-
    // taken from a previous subscription, because it's processing a renewal, and such
29+
30-
    // renewal should keep the original prices, in the original currency.
30+
31
    return self::get_price_in_currency($price);
32-
      $to_currency = get_woocommerce_currency();
32+
33
}