Skip to content

Instantly share code, notes, and snippets.

@dangoodman
Last active January 12, 2017 20:37
Show Gist options
  • Save dangoodman/363898346c3f2afccf53fa8104e62a29 to your computer and use it in GitHub Desktop.
Save dangoodman/363898346c3f2afccf53fa8104e62a29 to your computer and use it in GitHub Desktop.
Round WooCommerce shipping rates to upper close 0.05 (for Swiss franc)
<?php
// Paste everything below this line to your theme's functions.php file.
add_filter('woocommerce_package_rates', 'round_shipping_price_for_swiss_franc');
function round_shipping_price_for_swiss_franc($rates)
{
if (is_array($rates)) {
foreach ($rates as $rate) {
$rate->cost = ceil($rate->cost / 0.05) * 0.05;
}
}
return $rates;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment