Automattic\WooCommerce\StoreApi\Routes\V1\Ucp

CatalogProduct::normalize_selected │ private │ WC 1.0

Normalize selected options from the request payload.

Method of the class: CatalogProduct{}

No Hooks.

Returns

array.

Usage

// private - for code of main (parent) class only
$result = $this->normalize_selected( $selected ): array;
$selected(array) (required)
Raw selected options.

CatalogProduct::normalize_selected() code WC 11.3.0

private function normalize_selected( array $selected ): array {
	$normalized = array();

	foreach ( $selected as $option ) {
		if ( ! is_array( $option ) || ! isset( $option['name'], $option['label'] ) ) {
			continue;
		}

		$entry = array(
			'name'  => strval( $option['name'] ),
			'label' => strval( $option['label'] ),
		);

		if ( isset( $option['id'] ) ) {
			$entry['id'] = strval( $option['id'] );
		}

		$normalized[] = $entry;
	}

	return $normalized;
}