Automattic\WooCommerce\Blocks\BlockTypes

AddToCartWithOptionsQuantitySelector::add_stepper_classes()privateWC 1.0

Add classes to the Quantity Selector needed for the stepper style.

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

Хуков нет.

Возвращает

Строку. The Quantity Selector HTML with classes added.

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

// private - только в коде основоного (родительского) класса
$result = $this->add_stepper_classes( $product_html );
$product_html(строка) (обязательный)
The Quantity Selector HTML.

Код AddToCartWithOptionsQuantitySelector::add_stepper_classes() WC 9.8.5

private function add_stepper_classes( $product_html ) {
	$html = new \WP_HTML_Tag_Processor( $product_html );

	// Add classes to the form.
	while ( $html->next_tag( array( 'class_name' => 'quantity' ) ) ) {
		$html->add_class( 'wc-block-components-quantity-selector' );
	}

	$html = new \WP_HTML_Tag_Processor( $html->get_updated_html() );
	while ( $html->next_tag( array( 'class_name' => 'input-text' ) ) ) {
		$html->add_class( 'wc-block-components-quantity-selector__input' );
	}

	return $html->get_updated_html();
}