Last active
March 6, 2024 14:22
-
-
Save PluginRepublicSupport/c23bd658f10aa2b20c0828cb003f9ea2 to your computer and use it in GitHub Desktop.
A number field template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* A number field template | |
* @since 2.0.0 | |
* @package WooCommerce Product Add-Ons Ultimate | |
*/ | |
// Exit if accessed directly | |
if( ! defined( 'ABSPATH' ) ) { | |
exit; | |
} | |
$min = isset( $item['field_minval'] ) ? $item['field_minval'] : '0'; | |
$max = isset( $item['field_maxval'] ) ? $item['field_maxval'] : ''; | |
$product_id = $product->get_id(); | |
$other_data = ''; | |
$require_required = apply_filters( 'pewc_only_validate_number_field_value_if_field_required', false, $product_id, $item ); | |
if ( $require_required ) | |
$other_data .= 'data-require-required="yes" '; | |
else | |
$other_data .= 'data-require-required="no" '; | |
printf( | |
'%s<input type="%s" class="pewc-form-field pewc-number-field pewc-number-field-%s" id="%s" name="%s" value="%s" min="%s" max="%s" step="%s" autocomplete="%s" %s>%s', | |
$open_td, // Set in functions-single-product.php | |
esc_attr( apply_filters('pewc_number_field_input_type', 'number', $product_id, $item) ), | |
esc_attr( $item['field_id'] ), | |
esc_attr( $id ), | |
esc_attr( $id ), | |
esc_attr( $value ), | |
esc_attr( $min ), | |
esc_attr( $max ), | |
apply_filters( 'pewc_number_field_step', '1', $item ), | |
apply_filters( 'pewc_autocomplete', 'off', $item ), | |
apply_filters( 'pewc_number_field_other_data', $other_data, $product_id, $item), | |
$close_td | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment