Automattic\WooCommerce\Blocks\BlockTypes

AddToCartWithOptionsQuantitySelector::add_stepper_classes()privateWC 1.0

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

Method of the class: AddToCartWithOptionsQuantitySelector{}

No Hooks.

Return

String. The Quantity Selector HTML with classes added.

Usage

// private - for code of main (parent) class only
$result = $this->add_stepper_classes( $product_html );
$product_html(string) (required)
The Quantity Selector HTML.

AddToCartWithOptionsQuantitySelector::add_stepper_classes() code WC 9.6.1

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();
}