<?php // only copy this line if needed
/**
* Filter the quantity input's pattern attribute to fix the "Please match
* the requested format" HTML validation error that occurs when using
* WooCommerce Measurement Price Calculator with the Enfold theme
*
* @props to mensmaximus {@link https://github.com/mensmaximus} for the
* proposed solution
*
* @param string $pattern the value of the input element's pattern attribute
* @return string the updated pattern to allow floats
*/
function sv_wc_mpc_quantity_input_pattern_enfold_theme( $pattern ) {
if ( has_filter( 'woocommerce_stock_amount', 'floatval' ) ) {
$pattern = '^\d*(\.\d*)?$';
}
return $pattern;
}
add_filter( 'woocommerce_quantity_input_pattern', 'sv_wc_mpc_quantity_input_pattern_enfold_theme' );