Automattic\WooCommerce\Internal\CLI\Migrator\Platforms\Webflow

WebflowMapper::get_currency_decimalsprivateWC 1.0

Get the number of decimal places (minor units) for an ISO currency code.

Reads core's i18n/locale-info.php so the migrator stays in sync with WooCommerce's own per-currency data. Falls back to 2 for unknown codes.

Method of the class: WebflowMapper{}

No Hooks.

Returns

Int.

Usage

// private - for code of main (parent) class only
$result = $this->get_currency_decimals( $currency ): int;
$currency(string) (required)
ISO 4217 currency code.

WebflowMapper::get_currency_decimals() code WC 11.0.1

private function get_currency_decimals( string $currency ): int {
	if ( null === $this->currency_decimals ) {
		$this->currency_decimals = array();
		$locale_info             = include WC()->plugin_path() . '/i18n/locale-info.php';
		if ( is_array( $locale_info ) ) {
			foreach ( $locale_info as $info ) {
				if ( isset( $info['currency_code'], $info['num_decimals'] ) ) {
					$this->currency_decimals[ $info['currency_code'] ] = (int) $info['num_decimals'];
				}
			}
		}
	}
	return $this->currency_decimals[ strtoupper( $currency ) ] ?? 2;
}