首页 > 解决方案 > 由于税收,WooCommerce 中的四舍五入问题

问题描述

我添加了不含税的 WooCommerce 产品价格。

我的客户给我发了一份包含税的产品价格清单。加税后,产品需要以 65.25 欧元的价格出售。

现在的问题是它在计算税后显示为 65,24 欧元。我希望价格为 65,20 欧元或 65,25 欧元,因为它看起来更干净。是否有任何功能只会创建 5 美分的步长。

我找到了这个功能,但这仅适用于购物车中的总价。我希望每个产品都能做到这一点

add_filter( 'woocommerce_calculated_total', 'my_custom_roundoff' );
function my_custom_roundoff( $total ) {
$round_num = round($total / 0.05) * 0.05;
$total = number_format($round_num, 2); // this is required for showing zero in the last decimal
return $total;
}

标签: phpwordpresswoocommercepricetax

解决方案


推荐阅读