I'm a newbie in PHP, and for a woocommerce I'm trying to multiply a price by 2.
$priceOriginal = WC()->cart->get_cart_subtotal(); // return 450,00€
$priceNoCur = preg_replace( '/&.*?;/', '', $priceOriginal ); // return 450,00
$priceNoCurDot = preg_replace( '/,/', '.', $priceNoCur); // return 450.00
$priceFinalDot = floatval($priceNoCurDot) * 2;
echo $priceFinalDot; // return 0
I found how to delete de euro sign and change the coma by a dot, but when I multiply by two my result is 0 … why !?
SOLUTION
I find a other way to call the price : $priceOriginal = WC()->cart->total;
then I was able to multiply this number as a normal calculation.