Skip to content

Instantly share code, notes, and snippets.

@ChromeOrange
Created April 9, 2015 03:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChromeOrange/b30ba62eac9edb416b14 to your computer and use it in GitHub Desktop.
Save ChromeOrange/b30ba62eac9edb416b14 to your computer and use it in GitHub Desktop.
Fix PayPal Rounding Issues. Add to theme functions.php file
add_filter( 'woocommerce_paypal_args', 'fix_paypal_rounding_errors', 10, 2 );
function fix_paypal_rounding_errors ( $paypal_args = NULL, $order = NULL ) {
if( $paypal_args ) {
foreach( $paypal_args as $key => $value ) {
if( substr( $key, 0, 7 ) == 'amount_' || substr( $key, 0 , 9 ) == 'shipping_' ) {
$paypal_args[$key] = number_format( round($value,2), 2, '.', '' );
}
}
}
return $paypal_args;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment