尝试删除此代码输出的第二个小数点后的数字!有什么想法吗?
add_filter( 'woocommerce_product_get_weight', 'volumetric_calculations', 10, 2 );
function volumetric_calculations( $weight, $product ) {
$dim_weight = $product->get_length() * $product->get_width() * $product->get_height() / 5000;
return $dim_weight > $weight ? $dim_weight : $weight;
}发布于 2021-08-23 11:55:01
试试这个:
return $dim_weight > $weight ? number_format($dim_weight, 2, '.', '') : number_format($weight, 2, '.', '');或
$output = $dim_weight > $weight ? $dim_weight : $weight;
return number_format($output, 2, '.', '')而不是
return $dim_weight > $weight ? $dim_weight : $weight;https://stackoverflow.com/questions/68891932
复制相似问题