Automattic\WooCommerce\Blocks\BlockTypes\AddToCartWithOptions

Utils::add_quantity_stepper_classes │ public static │ WC 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 11.3.0

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

	while ( $processor->next_tag() ) {
		if (
			$processor->get_tag() === 'DIV' &&
			$processor->has_class( 'quantity' )
		) {
			$processor->add_class( 'wc-block-components-quantity-selector' );
		}

		if (
			$processor->get_tag() === 'INPUT' &&
			$processor->has_class( 'qty' ) &&
			$processor->get_attribute( 'type' ) !== 'hidden'
		) {
			$processor->add_class( 'wc-block-components-quantity-selector__input' );
		}
	}

	return $processor->get_updated_html();
}