/**
 * Register a new currency in WooCommerce.
 *
 * @param array $currencies WooCommerce currencies.
 *
 * @return array
 */
function dorzki_add_new_currency( $currencies ) {

  if( ! isset( $currencies['LPS'] ) ) {

    $currencies['LPS'] = __( 'Loyalty Points', 'dorzki' );

  }

  return $currencies;

}

add_filter( 'woocommerce_currencies', 'dorzki_add_new_currency' );


/**
 * Register a new currency symbol in WooCommerce.
 *
 * @param array $symbols WooCommerce currencies symbols.
 *
 * @return array
 */
function dorzki_add_new_currency_symbol( $symbols ) {

  if( ! isset( $symbols['LPS'] ) ) {

    $symbols['LPS'] = '§';

  }

  return $symbols;

}

add_filter( 'woocommerce_currency_symbols', 'dorzki_add_new_currency_symbol' );

How to use it?

Usually adding functionality to a WordPress site is by creating a plugin.
However you can simply copy the code and paste it in your child theme’s functions.php file at the end of the file, just before ?>.

For JavaScript code you will need to add them to your theme’s main JavaScript file.

Having issues with the code?

If the code doesn’t work or you get an error please let us know in the comments section.
We will do our best to fix it as-soon-as-possible and update the code on this page.

Comments

Leave a Reply