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

WebflowMapper::normalize_weight_unitprivateWC 1.0

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

Method of the class: WebflowMapper{}

No Hooks.

Returns

String.

Usage

// private - for code of main (parent) class only
$result = $this->normalize_weight_unit( $unit ): string;
$unit(string) (required)
Raw unit string.

WebflowMapper::normalize_weight_unit() code WC 11.0.1

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