In our store we enter prices including tax. On frontend we hide decimals (In Sweden we don't really use decimals anymore in prices), but backend we keep them. This is why: https://krokedil.com/dont-display-prices-with-0-decimals-in-woocommerce/
We use the function from the link above to hide the decimals on frontend and have also added a function to round off coupons at front end.
/**
* Trim zeros in price decimals
**/
add_filter( 'woocommerce_price_trim_zeros', '__return_true' );
function iconic_was_loop_position( $position ) {
return 'woocommerce_after_shop_loop_item_title';
}
add_filter( 'iconic_was_loop_position', 'iconic_was_loop_position', 10, 1 );
/**
* Round off decimals for coupons
**/
function filter_woocommerce_coupon_get_discount_amount( $discount,
$discounting_amount, $cart_item, $single, $instance ) {
$discount = ceil( $discount );
return $discount;
}
add_filter( 'woocommerce_coupon_get_discount_amount',
'filter_woocommerce_coupon_get_discount_amount', 10, 5 );
This works well for both prices and percentage coupons/discounts. However, say I have a coupon with a fixed cart amount of SEK400, when using it the amount instead changes to SEK402. I guess this has to do with how woo applies the coupons combined with the rounding filter.
So my question is, is it possible to exclude the fixed cart coupons from the rounding function in some way?