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

WebflowMapper::get_currency_decimals │ private │ WC 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.

Метод класса: WebflowMapper{}

Хуков нет.

Возвращает

int.

Использование

// private - только в коде основоного (родительского) класса
$result = $this->get_currency_decimals( $currency ): int;
$currency(строка) (обязательный)
ISO 4217 currency code.

Код WebflowMapper::get_currency_decimals() WC 11.2.2

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;
}