Skip to content

Instantly share code, notes, and snippets.

@lorenzocaum
Created November 8, 2015 02:12
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lorenzocaum/08835dff65dececa2f94 to your computer and use it in GitHub Desktop.
Save lorenzocaum/08835dff65dececa2f94 to your computer and use it in GitHub Desktop.
How to remove decimals from the total calculation in Gravity Forms

Add the sample code below to your child theme's functions.php file or in a site specific plugin.

<?php
//* Do NOT include the opening php tag

//* Remove decimals from total calculation in Gravity Forms
function gf_update_currency( $currencies ) {
	$currencies['USD'] = array(
	'name' => __( 'U.S. Dollar', 'gravityforms' ),
	'symbol_left' => '$',
	'symbol_right' => '',
	'symbol_padding' => '',
	'thousand_separator' => ',',
	'decimal_separator' => '.',
	'decimals' => 0
);
return $currencies;
}
add_filter( 'gform_currencies', 'gf_update_currency' );
@yourspanishguide
Copy link

Hello I implemented the same code for my Gravity forms in €.

The problem is that now stripe understands that 1€ = 0.01 €. I don't know how to fix that.

If I remove the code it works perfect, but then I still have to show the decimals.

//** Quitar deciamles de gravityforms

add_filter( 'gform_currencies', 'update_currency' );
function update_currency( $currencies ) {
$currencies['EUR'] = array(
'name' => __( 'Euro', 'gravityforms' ),
'symbol_left' => '€',
'symbol_right' => '',
'symbol_padding' => ' ',
'thousand_separator' => ',',
'decimal_separator' => '.',
'decimals' => 0
);

return $currencies;
}

@atinguptajammu
Copy link

Hello I implemented the same code for my Gravity forms in €.

The problem is that now stripe understands that 1€ = 0.01 €. I don't know how to fix that.

If I remove the code it works perfect, but then I still have to show the decimals.

//** Quitar deciamles de gravityforms

add_filter( 'gform_currencies', 'update_currency' );
function update_currency( $currencies ) {
$currencies['EUR'] = array(
'name' => __( 'Euro', 'gravityforms' ),
'symbol_left' => '€',
'symbol_right' => '',
'symbol_padding' => ' ',
'thousand_separator' => ',',
'decimal_separator' => '.',
'decimals' => 0
);

return $currencies;
}

So did you get the solution ? i also need the solution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment