The ACF number field will return an integer.
In php you’ll never have some decimal with an integer value, you have to work with float values.
Maybe you could simply try something like this
$price_html = $product->get_price(); //It will return a string
$x = get_field(‘custom-price’); //Integer
$float_price = floatval($price_html); //Float
$float_custom_price = floatval($x); //Float
$finalPrice = ($float_price + $float_custom_price); //Float
But this will only display your custom price.
If you want to actually modify your price you have to use woocommerce filters.
In product page :
// Simple, grouped and external products
add_filter(‘woocommerce_product_get_price’, ‘custom_price’, 99, 2 );
add_filter(‘woocommerce_product_get_regular_price’, ‘custom_price’, 99, 2 );
add_filter(‘woocommerce_product_variation_get_regular_price’, ‘custom_price’, 99, 2 );
add_filter(‘woocommerce_product_variation_get_price’, ‘custom_price’, 99, 2 );
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
The ACF site is currently experiencing some issues.— Advanced Custom Fields (@wp_acf) September 29, 2022
We apologize for the inconvenience and we are working hard to get it back up and running as soon as possible.
© 2022 Advanced Custom Fields.