how to add new Currency to learnPress plugin
Viewing 2 reply threads
-
AuthorPosts
-
-
January 13, 2018 at 5:32 PM #249042
Milad
ParticipantHello Thimpress
I’m using your leanpress plugin on my own WordPress theme, I want to add a new currency to the plugin and as far as surfed web I found a piece of code that should be added to theme function template. this is the code:add_filter( 'learn_press_get_payment_currencies', 'add_my_currency' ); function add_my_currency( $currencies ) { $currencies['PKR'] = 'Pakistan'; return $currencies; } add_filter('learn_press_currency_symbol', 'add_my_currency_symbol', 10, 2); function add_my_currency_symbol( $currency_symbol, $currency ) { switch( $currency ) { case 'PKR': $currency_symbol = 'Rs.'; break; } return $currency_symbol; }
is this code accurate? however, when I add it to my theme function template, in learnpress setting it shows the country name but not the currency symbol.
please help me with this. thanks -
January 15, 2018 at 4:17 PM #249709
Milad
ParticipantUP
-
January 15, 2018 at 4:41 PM #249747
Anonymous
InactiveDear Milad,
The reason is due to you haven’t add symbol in that code. Please see the code below.
/** * Add new currency * * @param $currencies * * @return mixed */ function thim_add_learnpress_currency( $currencies ) { $currencies['PEN'] = 'Peruvian Sol - S/.'; return $currencies; } add_filter( 'learn_press_get_payment_currencies', 'thim_add_learnpress_currency' ); /** * Add new currency symbol * * @param $currency_symbol * @param $currency * * @return string */ function thim_new_learnpress_currency_symbol( $currency_symbol, $currency ) { if ( $currency == 'PEN' ) { $currency_symbol = 'S/.'; } return $currency_symbol; } add_filter( 'learn_press_currency_symbol', 'thim_new_learnpress_currency_symbol', 10, 2 );
Best regards,
Huyen Anh
Â
-
-
AuthorPosts
Viewing 2 reply threads
You must be logged in to reply to this topic. You can click here