Code snippets to add Latin American currencies in Gravity Forms

When dealing with international transactions within Gravity Forms, having a diverse range of currency options is essential. However, by default, Gravity Forms doesn’t include Latin American currencies. In this article, we will share a code snippet snippet with you to include all the Latin American currencies to the Gravity Forms.

Argentine Peso

/**
 * Add Argentina Peso to Gravity Forms
 */
function gf_add_argentina_peso( $currencies ) {
	$currencies['ARS'] = array(
		'name'               => __( 'Argentine Peso', 'gravityforms' ),
		'symbol_left'        => '$',
		'symbol_right'       => '',
		'symbol_padding'     => ' ',
		'thousand_separator' => '.',
		'decimal_separator'  => ',',
		'code'               => 'ARS',
		'decimals'           => 2,
	);

	return $currencies;
}

add_filter( 'gform_currencies', 'gf_add_argentina_peso' );

Belize Dollar

/**
 * Add Belize Dollar to Gravity Forms
 */
function gf_add_belize_dollar( $currencies ) {
	$currencies['BZD'] = array(
		'name'               => __( 'Belize Dollar', 'gravityforms' ),
		'symbol_left'        => 'BZ$',
		'symbol_right'       => '',
		'symbol_padding'     => ' ',
		'thousand_separator' => ',',
		'decimal_separator'  => '.',
		'code'               => 'BZD',
		'decimals'           => 2,
	);

	return $currencies;
}

add_filter( 'gform_currencies', 'gf_add_belize_dollar' );

Belize Dollar

/**
 * Add Bolivian Boliviano to Gravity Forms
 */
function gf_add_bolivian_boliviano( $currencies ) {
	$currencies['BOB'] = array(
		'name'               => __( 'Bolivian Boliviano', 'gravityforms' ),
		'symbol_left'        => 'Bs.',
		'symbol_right'       => '',
		'symbol_padding'     => ' ',
		'thousand_separator' => '.',
		'decimal_separator'  => ',',
		'code'               => 'BOB',
		'decimals'           => 2,
	);

	return $currencies;
}

add_filter( 'gform_currencies', 'gf_add_bolivian_boliviano' );

Chilean Peso

/**
 * Add Chilean Peso to Gravity Forms
 */
function gf_add_chilean_peso( $currencies ) {
	$currencies['CLP'] = array(
		'name'               => __( 'Chilean Peso', 'gravityforms' ),
		'symbol_left'        => '$',
		'symbol_right'       => '',
		'symbol_padding'     => ' ',
		'thousand_separator' => '.',
		'decimal_separator'  => ',',
		'code'               => 'CLP',
		'decimals'           => 0,
	);

	return $currencies;
}

add_filter( 'gform_currencies', 'gf_add_chilean_peso' );

Colombian peso

/**
 * Add Colombian peso to gravity forms.
 *
 * @return array
 */
function gf_add_colobian_peso( $currencies ) {
	$currencies['COP'] = array(
		'name'               => __( 'Colombian Peso', 'gravityforms' ),
		'symbol_left'        => 'Col$',
		'symbol_right'       => '',
		'symbol_padding'     => ' ',
		'thousand_separator' => '.',
		'decimal_separator'  => ',',
		'code'               => 'COP',
		'decimals'           => 2,
	);

	return $currencies;

}
add_filter( 'gform_currencies', 'gf_add_colobian_peso' );

Costa Rican colón

/**
 *  Add Costa Rican colón.
 *
 * @param array $currencies
 * 
 * @return array
 */
function gf_add_costa_rican_colon( $currencies ) {
	$currencies['CRC'] = array(
		'name'               => __( 'Costa Rican Colón', 'gravityforms' ),
		'symbol_left'        => '₡',
		'symbol_right'       => '',
		'symbol_padding'     => ' ',
		'thousand_separator' => '.',
		'decimal_separator'  => ',',
		'code'               => 'CRC',
		'decimals'           => 2,
	);

	return $currencies;
}
add_filter( 'gform_currencies', 'gf_add_costa_rican_colon' );

Dominican Peso

/**
 * Add Dominican peso to gravity forms.
 * 
 * @param array $currencies
 * 
 * @return array
 */
function gf_add_dominican_peso( $currencies ) {
	$currencies['DOP'] = array(
		'name'               => __( 'Dominican Peso', 'gravityforms' ),
		'symbol_left'        => 'RD$',
		'symbol_right'       => '',
		'symbol_padding'     => ' ',
		'thousand_separator' => '.',
		'decimal_separator'  => ',',
		'code'               => 'DOP',
		'decimals'           => 2,
	);

	return $currencies;
}
add_filter( 'gform_currencies', 'gf_add_dominican_peso' );

Guatemalan Quetzal

/**
 * Add Guatemalan quetzal to gravity forms.
 *
 * @param array $currencies
 *
 * @return array
 */
function gf_add_guatemalan_quetzal( $currencies ) {
	$currencies['GTQ'] = array(
		'name'               => __( 'Guatemalan Quetzal', 'gravityforms' ),
		'symbol_left'        => 'Q',
		'symbol_right'       => '',
		'symbol_padding'     => ' ',
		'thousand_separator' => '.',
		'decimal_separator'  => ',',
		'code'               => 'GTQ',
		'decimals'           => 2,
	);

	return $currencies;
}
add_filter( 'gform_currencies', 'gf_add_guatemalan_quetzal' );

Honduran lempira

/**
 * Add Honduran lempira to gravity forms.
 * 
 * @param array $currencies
 * 
 * @return array
 */
function gf_add_honduran_lempira( $currencies ) {
	$currencies['HNL'] = array(
		'name'               => __( 'Honduran Lempira', 'gravityforms' ),
		'symbol_left'        => 'L',
		'symbol_right'       => '',
		'symbol_padding'     => ' ',
		'thousand_separator' => '.',
		'decimal_separator'  => ',',
		'code'               => 'HNL',
		'decimals'           => 2,
	);

	return $currencies;
}

add_filter( 'gform_currencies', 'gf_add_honduran_lempira' );

Nicaraguan Córdoba

/**
 * Add Nicaraguan córdoba to gravity forms.
 * 
 * @param array $currencies
 * 
 * @return array
 */
function gf_add_nicaraguan_cordoba( $currencies ) {
	$currencies['NIO'] = array(
		'name'               => __( 'Nicaraguan Córdoba', 'gravityforms' ),
		'symbol_left'        => 'C$',
		'symbol_right'       => '',
		'symbol_padding'     => ' ',
		'thousand_separator' => '.',
		'decimal_separator'  => ',',
		'code'               => 'NIO',
		'decimals'           => 2,
	);

	return $currencies;
}

add_filter( 'gform_currencies', 'gf_add_nicaraguan_cordoba' );

Panamanian Balboa

/**
 * Add Panamanian balboa to gravity forms.
 * 
 * @param array $currencies
 * 
 * @return array
 */
function gf_add_panamanian_balboa( $currencies ) {
	$currencies['PAB'] = array(
		'name'               => __( 'Panamanian Balboa', 'gravityforms' ),
		'symbol_left'        => 'B/.',
		'symbol_right'       => '',
		'symbol_padding'     => ' ',
		'thousand_separator' => '.',
		'decimal_separator'  => ',',
		'code'               => 'PAB',
		'decimals'           => 2,
	);

	return $currencies;
}

add_filter( 'gform_currencies', 'gf_add_panamanian_balboa' );

Paraguayan Guarani

/**
 * Add Paraguayan guarani to gravity forms.
 * 
 * @param array $currencies
 * 
 * @return array
 */
function gf_add_paraguayan_guarani( $currencies ) {
	$currencies['PYG'] = array(
		'name'               => __( 'Paraguayan Guarani', 'gravityforms' ),
		'symbol_left'        => '₲',
		'symbol_right'       => '',
		'symbol_padding'     => ' ',
		'thousand_separator' => '.',
		'decimal_separator'  => ',',
		'code'               => 'PYG',
		'decimals'           => 2,
	);

	return $currencies;
}

add_filter( 'gform_currencies', 'gf_add_paraguayan_guarani' );

Peruvian Sol

/**
 * Add Peruvian Sol to gravity forms.
 *
 * @param array $currencies
 *
 * @return array
 */
function gf_add_peruvian_sol( $currencies ) {
	$currencies['PEN'] = array(
		'name'               => __( 'Peruvian Sol', 'gravityforms' ),
		'symbol_left'        => 'S/.',
		'symbol_right'       => '',
		'symbol_padding'     => ' ',
		'thousand_separator' => '.',
		'decimal_separator'  => ',',
		'code'               => 'PEN',
		'decimals'           => 2,
	);

	return $currencies;
}

add_filter( 'gform_currencies', 'gf_add_peruvian_sol' );

Uruguayan Peso

/**
 * Add Uruguayan peso to gravity forms.
 * 
 * @param array $currencies
 * 
 * @return array
 */
function gf_add_uruguayan_peso( $currencies ) {
	$currencies['UYU'] = array(
		'name'               => __( 'Uruguayan Peso', 'gravityforms' ),
		'symbol_left'        => '$U',
		'symbol_right'       => '',
		'symbol_padding'     => ' ',
		'thousand_separator' => '.',
		'decimal_separator'  => ',',
		'code'               => 'UYU',
		'decimals'           => 2,
	);

	return $currencies;
}

add_filter( 'gform_currencies', 'gf_add_uruguayan_peso' );

Venezuelan Bolívar

/**
 * Add Venezuelan bolívar to gravity forms.
 *
 * @param array $currencies
 *
 * @return array
 */
function gf_add_venezuelan_bolivar( $currencies ) {
	$currencies['VES'] = array(
		'name'               => __( 'Venezuelan Bolívar', 'gravityforms' ),
		'symbol_left'        => 'Bs.S',
		'symbol_right'       => '',
		'symbol_padding'     => ' ',
		'thousand_separator' => '.',
		'decimal_separator'  => ',',
		'code'               => 'VES',
		'decimals'           => 2,
	);

	return $currencies;
}

add_filter( 'gform_currencies', 'gf_add_venezuelan_bolivar' );

If you want to add all these currencies in the Gravity Forms with a single code snippet then you can you can find the compiled snippet here: https://gist.github.com/pramodjodhani/dcd982be8c3540132f49fd9f54a40559


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *