/** * Given a number formatted by WooCommerce, it returns the raw number. Input * number must not include the Currency symbol (i.e. it must only contain digits, * the decimal separator and the thousand separator) . * * @param string formatted_number A number containing a decimal separator and, * optionally, the thousand separator. * @return double A raw number. */ function get_raw_number($formatted_number) { //$num_decimals = (int)get_option('woocommerce_price_num_decimals'); $decimal_sep = Settings::decimal_separator(); $thousands_sep = Settings::thousand_separator(); // Remove Thousands separator $raw_number = str_replace($thousands_sep, '', $formatted_number); // Replace whatever Decimal separator with the dot. At this point, number is // raw, i.e. in format "12345.67" $raw_number = str_replace($decimal_sep, '.', $raw_number); return $raw_number; }
/** * Class constructor. */ public function __construct($settings_key = self::SETTINGS_KEY, $textdomain = '', \Aelia\WC\Settings_Renderer $renderer = null) { if (empty($renderer)) { // Instantiate the render to be used to generate the settings page $renderer = new \Aelia\WC\Settings_Renderer(); } parent::__construct($settings_key, $textdomain, $renderer); add_action('admin_init', array($this, 'init_settings')); // If no settings are registered, save the default ones if ($this->load() === null) { $this->save(); } }