Automattic\WooCommerce\Blocks\BlockTypes
AddToCartForm::add_stepper_classes_to_add_to_cart_form_input
Add classes to the Add to Cart form input needed for the stepper style.
Method of the class: AddToCartForm{}
No Hooks.
Returns
String. The Add to Cart form HTML with classes added.
Usage
// private - for code of main (parent) class only $result = $this->add_stepper_classes_to_add_to_cart_form_input( $product_html );
- $product_html(string) (required)
- The Add to Cart form HTML.
AddToCartForm::add_stepper_classes_to_add_to_cart_form_input() AddToCartForm::add stepper classes to add to cart form input code WC 10.4.3
private function add_stepper_classes_to_add_to_cart_form_input( $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();
}