Overriding properly WooCommerce function WC_Price() in a clean way
To add your custom html tag <span class="custom-prc">0000</span>
around the price, you will need to use a hooked function in formatted_woocommerce_price
filter hook this way:
add_filter( 'formatted_woocommerce_price', 'span_custom_prc', 10, 5 );function span_custom_prc( $number_format, $price, $decimals, $decimal_separator, $thousand_separator){ return '<span class="custom-prc">'.$number_format.'</span>';}
Code goes in function.php file of your active child theme (or theme) or also in any plugin file.
The code is tested and works with WooCommerce 3+
Then you will get this html output (for example with 42,00 euros
):
<span class="price"> <span class="woocommerce-Price-amount amount"> <span class="custom-prc">42,03</span> " " <span class="woocommerce-Price-currencySymbol">€</span> </span></span>