Automattic\WooCommerce\Blocks\BlockTypes\AddToCartWithOptions
Utils::has_visible_quantity_input
Check if the HTML content has a visible quantity input.
Method of the class: Utils{}
No Hooks.
Returns
true|false. True if the HTML content has a visible input, false otherwise.
Usage
$result = Utils::has_visible_quantity_input( $html_content );
- $html_content(string) (required)
- The HTML content.
Utils::has_visible_quantity_input() Utils::has visible quantity input code WC 10.5.0
public static function has_visible_quantity_input( $html_content ) {
$processor = new \WP_HTML_Tag_Processor( $html_content );
while ( $processor->next_tag() ) {
if (
$processor->get_tag() === 'INPUT' &&
$processor->get_attribute( 'name' ) === 'quantity' &&
$processor->get_attribute( 'type' ) !== 'hidden'
) {
return true;
}
}
return false;
}