Modify the decimal precision of a currency

The following snippet modified how many decimals a currency uses.

This could be useful if you prefer not to use any decimals at all (0) or your customers are going to use a wallet that doesn’t have the same decimal support as the currency itself does.

/**
 @brief		Change the decimal precision of a currency.
 @since		2018-12-09 17:24:52
**/
function mcc_mycryptocheckout_get_currencies( $action )
{
 $currencies = [
 	'BTC' => 4,
 	'ETH' => 0,		// No decimals
 ];
 foreach( $currencies as $currency_id => $decimal_precision )
 {
 // Check that MCC has the currency.
 if ( ! $action->currencies->has( $currency_id ) )
  return;
 // Change the decimal precision to 0, to not have any decimals at all.
 $action->currencies->get( $currency_id )
  ->decimal_precision = $decimal_precision;
 }
}
add_action( 'mycryptocheckout_get_currencies', 'mcc_mycryptocheckout_get_currencies' );