I need visually remove the decimal place (00) from the price and maintain only the comma or point after the first integer.
E.g: $ 10,
E.g: $ 7,
This is the code:
$retorno .= "<div class='cc_btn_checkout_container d-none' data-price='".$product->get_price()."'><div
The object receives the price: .$product->get_price(). = $ 10.00
The price is displayed here inside:
<p id='cc_btn_amount'>$ 10.00</p>
I’m trying with this function….but until now nothing happens.
$retorno .= "<div class='cc_btn_checkout_container d-none' data-price='".number_format($product->get_price(), 0)."'><div
The number need to be displayed like this: $ 10,
How can I do this? Is that the correct function to be used in this case?
Obs: I must maintain the comma after the price, I cannot in this case remove the comma or the point as others Woo functions does.
2
Answers
You can use this filter
http://hookr.io/filters/woocommerce_price_format/
or this:
Check out the functions in this article from Tyche Softwares
Just remove $decimal from the return and the
<sup>
if you don’t need it."If you want the decimal separator in the superscript, you can easily do that too. If you look at our filter, it has an argument called $decimal_separator. This is the same separator which we have set in the WooCommerce settings. We just have to include that in our final result. Here is an example –