Automattic\WooCommerce\Blocks\BlockTypes\AddToCartWithOptions

Utils::add_quantity_stepper_classespublic staticWC 1.0

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

Method of the class: Utils{}

No Hooks.

Returns

String. The Quantity Selector HTML with classes added.

Usage

$result = Utils::add_quantity_stepper_classes( $quantity_html );
$quantity_html(string) (required)
The Quantity Selector HTML.

Utils::add_quantity_stepper_classes() code WC 10.6.2

public static function add_quantity_stepper_classes( $quantity_html ) {
	$processor = new \WP_HTML_Tag_Processor( $quantity_html );

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

	while ( $processor->next_tag( array( 'class_name' => 'input-text' ) ) ) {
		$processor->add_class( 'wc-block-components-quantity-selector__input' );
	}

	return $processor->get_updated_html();
}