如何在Woocommerce中制作千元分隔符

I wrote this code (on woocommerce/single-product/price.php) a few months ago but I lost it, I was lucky to recover the code but in its first phase. Before the result gave me a thousand separation, I think it was because of the "preg_replace" function.

<?php echo '$' . round((preg_replace('/^[\.]/', '', $product->get_price()) *1.04)); ?>

The result that shows me is similar to: $311896. The format I'm looking for: $311.896

I will show you how it works. I add a tax to a payment gateway (that's why I used formula x1.04). It is shown in this way: The original price if it is formatted correctly, but my code is not. It is a headache.

$a='299900';
echo '$' . number_format($a*1.04); 

the output is: $311,896

if you want to display "." instead of the "," you can do that via the function extra parameters, see http://php.net/manual/en/function.number-format.php

This is not needed in woocommerce, if you have set the thousand separator in Woocommerce general settings:

enter image description here

You just have to use the dedicated price formatting function wc_price() that will do everything for you even the currency symbol:

<?php echo wc_price( $product->get_price() * 1.04 ); ?>

It is recommended to use it with wc_get_price_to_display() function this way:

<?php echo wc_price( wc_get_price_to_display( $product, array( 'price' => $product->get_price() * 1.04 ) ) ); ?>