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

WebflowMapper::normalize_weight_unit │ private │ WC 1.0

Normalize a Webflow weight unit string to a wc_get_weight compatible unit.

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

Хуков нет.

Возвращает

string.

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

// private - только в коде основоного (родительского) класса
$result = $this->normalize_weight_unit( $unit ): string;
$unit(строка) (обязательный)
Raw unit string.

Код WebflowMapper::normalize_weight_unit() WC 11.2.2

private function normalize_weight_unit( string $unit ): string {
	$map = array(
		'oz'    => 'oz',
		'lb'    => 'lbs',
		'lbs'   => 'lbs',
		'pound' => 'lbs',
		'g'     => 'g',
		'gram'  => 'g',
		'kg'    => 'kg',
	);
	return $map[ $unit ] ?? 'lbs';
}