Automattic\WooCommerce\Blocks\BlockTypes

AddToCartWithOptionsVariationSelector::render_variation_label()protectedWC 1.0

Render variation label.

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

Хуков нет.

Возвращает

Строку. Rendered label HTML.

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

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->render_variation_label( $attribute_name ): string;
$attribute_name(строка) (обязательный)
Name of the attribute.

Код AddToCartWithOptionsVariationSelector::render_variation_label() WC 9.8.5

protected function render_variation_label( $attribute_name ): string {
	$label_id   = esc_attr( 'attribute_' . sanitize_title( $attribute_name ) );
	$label_text = wc_attribute_label( $attribute_name );

	$html = sprintf(
		'<label class="wc-block-product-add-to-cart-attribute-label" for="%s">%s</label>',
		$label_id,
		esc_html( $label_text )
	);
	return $html;
}