• Resolved Florin

    (@florinschweiz)


    Hi there
    How can i make a hidden field which has the current time in it? Just to make other fields depending on what time we currently have.
    Best Regards
    Florin

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author ThemeHigh

    (@themehigh)

    We are checking your requirement with our technical team. We will get back to you once we get an update from them.

    Thank you!

    Plugin Author ThemeHigh

    (@themehigh)

    Please add the below code snippet in your child theme’s functions.php file to achieve your requirement.

    add_filter('woocommerce_form_field_hidden', 'th_woo_form_field_hidden', 11, 4);
    function th_woo_form_field_hidden($field, $key, $args, $value){
    	if(is_null($value) || (is_string($value) && $value === '')){
            $value = $args['default'];
        }
    
        if (isset($key) && $key == '<strong>field_name</strong>') {
        	date_default_timezone_set('<strong>Asia/Kolkata</strong>');
        	$value = date("h:i:sa");
    	}
    	$field  = '<input type="hidden" id="'. esc_attr($key) .'" name="'. esc_attr($key) .'" value="'. esc_attr( $value ) .'" class="'.esc_attr(implode(' ', $args['class'])).'" />';
    	return $field;
    }

    Replace field_name with your hidden field name and Asia/Kolkata with your corresponding timezone.

    Thank you!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘hidden Field’ is closed to new replies.