
seanmandrake(@seanmandrake)
2 Posts
Customers
Quote from seanmandrake on May 15, 2023, 13:37
Is there a hook to perform rounding on converted shipping costs?
For currency I found these (shortened for clarity) and this makes sense to me and works well, but shipping still remains 'untidy'
add_filter('woocs_raw_woocommerce_price', function ($price) {
return round($price * 2, 0) / 2;};
add_filter('woocs_woocommerce_variation_prices', function($price) {
return round($price * 2, 0) / 2;};[Note: I do have a purchase code but cant see where to add it :)]
Is there a hook to perform rounding on converted shipping costs?
For currency I found these (shortened for clarity) and this makes sense to me and works well, but shipping still remains 'untidy'
add_filter('woocs_raw_woocommerce_price', function ($price) {
return round($price * 2, 0) / 2;};
add_filter('woocs_woocommerce_variation_prices', function($price) {
return round($price * 2, 0) / 2;};[Note: I do have a purchase code but cant see where to add it :)]

Pablo Borysenco(@pavlo_borysenco)
34,196 Posts
Quote from Pablo Borysenco on May 16, 2023, 09:57
Hello
Try to add this in functions.php
add_filter('woocommerce_package_rates', function($rates, $package) {
if(!class_exists('WOOCS')){
return $rates;
}
global $WOOCS;
if ($WOOCS->current_currency != $WOOCS->default_currency) {
foreach ($rates as $key=>$rate) {
$rates[$key]->cost = round($rate->cost * 2, 0) / 2;
}
}
return $rates;
}, 99999, 2);
But keep in mind that this rounding occurs before taxes are calculated.
Hello
Try to add this in functions.php
add_filter('woocommerce_package_rates', function($rates, $package) {
if(!class_exists('WOOCS')){
return $rates;
}
global $WOOCS;
if ($WOOCS->current_currency != $WOOCS->default_currency) {
foreach ($rates as $key=>$rate) {
$rates[$key]->cost = round($rate->cost * 2, 0) / 2;
}
}
return $rates;
}, 99999, 2);
But keep in mind that this rounding occurs before taxes are calculated.