Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Contributor Mike Jolley

    (@mikejolley)

    function euro_5cent_rounding( $in ) {
      return round( $in / 5, 2 ) * 5;
    }
    add_filter( 'woocommerce_tax_round', 'euro_5cent_rounding' );
    Thread Starter Swissprice

    (@swissprice)

    Hello Mike,

    Thank you for your help.

    I just tried (pasted in functions.php) but it didn’t work.

    I believe it may be because the Swiss currency isn’t Euros but Swiss Francs (CHF).

    Plugin Contributor Mike Jolley

    (@mikejolley)

    Doesn’t matter in this case. This code only rounds the calculated TAXes nothing else.

    Thread Starter Swissprice

    (@swissprice)

    Hello Mike,

    Thank you for your reply.

    Unfortunately, it did no work. I still shows a VAT of .79 instead of .80, for exemple ??

    Any other suggestion?

    Plugin Contributor Mike Jolley

    (@mikejolley)

    If you enable the ’round at subtotal’ and also make this change:

    function euro_5cent_rounding( $in ) {
    	  return round( $in / 5, 2 ) * 5;
    	}
    	add_filter( 'woocommerce_tax_round', 'euro_5cent_rounding' );
    
    	function get_taxes_euro_5cent_rounding( $taxes ) {
    		return array_map( 'euro_5cent_rounding', $taxes );
    	}
    	add_filter( 'woocommerce_cart_get_taxes', 'get_taxes_euro_5cent_rounding' );

    Does it work then how you need?

    Thread Starter Swissprice

    (@swissprice)

    Hello Mike,

    It worked exactly as I needed!

    Your help was very appreciated! ??

    PS: to whoever who will uses this on their WooCommerce installation, do not forget to empty the WooCommerce caches in order to see the changes.

    Hi Mike,

    It worked exactly as needed. But there’s an issue at subtotal.

    Supposed, 62.55 + 47.70 + 103.90 = 214.15, but it turns out to be 214.12.
    Screenshot

    How do i get this solved?

    Thank you in advance!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Round VAT total to .X0’ is closed to new replies.