Support » Plugin: Easy Digital Downloads - Simple Ecommerce for Selling Digital Files » The problem of using edd_currency_symbol() filter

  • Hi!
    That’s the problem
    formatting.php

    line 121  $symbol = edd_currency_symbol( $currency );
    // I want add custom symbol (f.e. 'smb') for custom currency f.e. UAH
    // in function.php my theme
    //add_filter( 'edd_currency_symbol','edd_add_my_currency_symbol',10 ,2 );
    // OK $symbol='smb' now
    
    line 157 default :
    line 158 $formatted = $price . ' ' . $currency; // ???
    // as a result $formatted = 100 UAH not 100 smb (((

    https://wordpress.org/plugins/easy-digital-downloads/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author mordauk

    (@mordauk)

    You will first need to register the currency using edd_currencies: http://docs.easydigitaldownloads.com/article/272-adding-currency-support-eddcurrencies

    Hi!
    Of course, the UAH currency was added via this filter.
    But the problem is that if the currency is not in this list

    case "GBP" :
    case "BRL" :
    case "EUR" :
    case "USD" :
    case "AUD" :
    case "CAD" :
    case "HKD" :
    case "MXN" :
    case "SGD" :
    case "JPY" :

    will execute the default code.

    default :
    $formatted = $price . ' ' . $currency;

    // 100 UAH not 100 smb

    Or am I wrong?

    Plugin Author mordauk

    (@mordauk)

    Can you show me the exact filter / callback function you’re using?

    You will need to use the edd_currency_symbol filter to add a new symbol for your currency code that is registered as shown above.

    Note: please do not modify the files in the plugin directly. Use add_filter() to make changes, as shown in the documentation I linked above.

    // function.php  my theme
    
    function edd_add_my_currency_symbol($symbol,$currency) {
       if (!empty($currency) && $currency=='UAH') $symbol=' grn';
       return $symbol;
    }
    function pippin_extra_edd_currencies( $currencies ) {
    	$currencies['UAH'] = 'Ukrainian hryvnia';
    	return $currencies;
    }
    add_filter('edd_currencies', 'pippin_extra_edd_currencies');
    add_filter( 'edd_currency_symbol','edd_add_my_currency_symbol',10 ,2 );

    IMHO bug in function edd_currency_filter() formatting.php

    line 157 default :
    line 158 $formatted = $price . ' ' . $currency;

    must be

    line 157 default :
    line 158 $formatted = $price . ' ' . $symbol;

    Plugin Author mordauk

    (@mordauk)

    It’s not that way mainly because of backwards compatibility. Changing it now would have very adverse affects on existing websites.

    Which part of the code you posted above is not working as expected?

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘The problem of using edd_currency_symbol() filter’ is closed to new replies.