Skip to content

Instantly share code, notes, and snippets.

@ChromeOrange
Last active August 29, 2015 14:04
Show Gist options
  • Save ChromeOrange/9c158e66621fa06e2c86 to your computer and use it in GitHub Desktop.
Save ChromeOrange/9c158e66621fa06e2c86 to your computer and use it in GitHub Desktop.
Fix PayPal rounding error
/**
* Round Shipping in the event of PayPal errors
*/
add_filter( 'woocommerce_package_rates', 'fix_shipping_rounding_errors' , 10, 2 );
/**
*
*/
function fix_shipping_rounding_errors( $rates, $package ) {
foreach ( $rates as $rate ) {
$rate->cost = round( $rate->cost, absint( get_option( 'woocommerce_price_num_decimals' ) ) );
}
return $rates;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment