'WooCommerce - Product variation single price changes after delay

I am currently using a php snippet to adjust the amount of decimals displayed for a specific product category.

function custom_price_decimals( $decimals ) {
    if( is_product()) {
        global $post;
        $terms = wp_get_post_terms( $post->ID, 'product_cat' );
        foreach ( $terms as $term ) $categories[] = $term->slug;
        if ( in_array( 'standard-eyelets', $categories ) ) {
          $decimals = 3;
        }
        
    }       
    return $decimals;
}

add_filter( 'wc_get_price_decimals' , 'custom_price_decimals', 20, 1 );

This works but after a slight delay, for some reason for single variation prices, the 3 decimals changes back to two decimals. I disabled my other code snippets to see if they were causing the issue but they were not. Is there some sort of hook that happens to change the price back to 2 decimals? This does not happen for single or grouped products.

Price changes after delay

A similar question was asked here but never answered (Woocommerce: 3 decimals in product variation price)

I expected that the single variation price would display 3 decimals and it does. But then after a delay, it changes back to rounding to 2 decimals.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source