Add a custom currency / symbol in LearnPress

To add a custom currency in LearnPress, you should create child theme because this code is not affected by updates if using a child theme.

Then copy the code below  and paste it in  functions.php file (child theme) and swap out the currency code and symbol with your own (http://prntscr.com/infdqa).
/**
* Add new currency
*
* @param $currencies
*
* @return mixed
*/

add_filter('learn_press_get_payment_currencies', 'my_cbf_learn_press_get_payment_currencies', 10, 1 ); // for LearnPress 2
add_filter('learn-press/currencies', 'my_cbf_learn_press_get_payment_currencies', 10, 1 ); // for LearnPress 3
function my_cbf_learn_press_get_payment_currencies( $currencies ){
$currency_new = 'Code'; # Currency Code
$currency_name = __('Currency name', 'learnpress'); # Full name of Currency
if( !isset($currencies[$currency_new]) || ( isset($currencies[$currency_new]) && $currencies[$currency_new] !== $currency_name ) ) {
$currencies[$currency_new] = $currency_name;
}
return $currencies;
}
add_filter( 'learn_press_currency_symbol', 'my_cbf_learn_press_currency_symbol', 10, 2 );
function my_cbf_learn_press_currency_symbol( $currency_symbol, $currency ) {
$currency_new = 'Code'; # Currency Code
if( $currency == $currency_new ) {
$currency_symbol = 'Symbol'; # Symbol of currency
}
return $currency_symbol;
}

After saving changes, it should be available from your LearnPress / Settings / General / Currency (http://prntscr.com/infbjf).

Example: If you want to add Peruvian Sol currency with Code: PEN, Symbol: S/

You have to create child theme then add the code  below to functions.php file (child theme)
/**
* Add new currency
*
* @param $currencies
*
* @return mixed
*/

add_filter('learn_press_get_payment_currencies', 'my_cbf_learn_press_get_payment_currencies', 10, 1 ); // for LearnPress 2
add_filter('learn-press/currencies', 'my_cbf_learn_press_get_payment_currencies', 10, 1 ); // for LearnPress 3
function my_cbf_learn_press_get_payment_currencies( $currencies ){
$currency_new = 'PEN'; # Currency Code
$currency_name = __('Peruvian Sol - S/', 'learnpress'); # Full name of Currency
if( !isset($currencies[$currency_new]) || ( isset($currencies[$currency_new]) && $currencies[$currency_new] !== $currency_name ) ) {
$currencies[$currency_new] = $currency_name;
}
return $currencies;
}
add_filter( 'learn_press_currency_symbol', 'my_cbf_learn_press_currency_symbol', 10, 2 );
function my_cbf_learn_press_currency_symbol( $currency_symbol, $currency ) {
$currency_new = 'PEN'; # Currency Code
if( $currency == $currency_new ) {
$currency_symbol = 'S/'; # Symbol of currency
}
return $currency_symbol;
}

Best Deals
Get Eduma Now

For Only *
$439 $69

 
GRAB THE DEAL
* Hurry up! Offer ends this Friday!
close-link
ấdsa
ádasd
ádsad
Subscribe
Give it a try, you can unsubscribe anytime.
close-link
Download
LEARNPRESS
WordPress LMS
Download the best WordPress LMS now. Completely Free.
close-link
Learn More