to use approved google merchant, I need to send them the price in this format:
what I've got in my database actually is written like 100.000,00€
so to replace it, I've use:
$total_price = substr(str_replace(",", ".", str_replace(".", "", $order->info['total'])),0, -6);
Which is quite bad in my opinion. any thoughts on this?
You can use NumberFormatter::parseCurrency to parse a string into a double and a currency using the current formatter.
well regular expressions would help you keep things tidy, but you will still need to remove the dot you have lying around in there, and replacing the comma with a dot afterwards. once you have that, you can use
$str = preg_replace('/[^0-9.]+/', '', $str);
to eliminate any currency labeling you saved. Note to future you: when developing software for multi-currency transactions, you should separate values from currencies. this way you can keep a decimal value in the db and keep the type of currency in tnother and not bother with this all together.
have fun! let me know if you need anything else