In WooCommerce WordPress, ui-datepicker-year only displays 20 years.
P粉720716934
P粉720716934 2023-08-06 21:20:13
0
2
574
<p>I need to update the function.php file so that it displays 99 years instead of just 20 years. I'm using Bizberg theme. <br /><br />I tried this method without success in extending the time range, the problem is that the scrollbar still only allows 20 years, I need 99 years. </p><p><br /></p> <pre class="brush:php;toolbar:false;">function extend_date_of_birth_range() { ?> <script> jQuery(function($) { var currentYear = new Date().getFullYear(); var startYear = currentYear - 99; var endYear = currentYear - 10; // Replace "billing_date_of_birth" with the ID or name of your date of birth field $('#billing_date_of_birth').datepicker('option', { yearRange: startYear ':' endYear }); }); </script> <?php } add_action('wp_footer', 'extend_date_of_birth_range');</pre> <p><br /></p>
P粉720716934
P粉720716934

reply all(2)
P粉692052513

Try this

var dateRange = '"'+startYear+' : '+endYear+'"';

Place the "dateRange" variable as follows:

// Replace "billing_date_of_birth" with the ID or name of your date of birth field
$('#billing_date_of_birth').datepicker('option', {
     yearRange: dateRange
});
P粉071602406

Add this function to the function.php file, hope this helps you.

<?php 
function extend_date_of_birth_range() {
    ?>
    <script>
        jQuery(function($) {
            var currentYear = new Date().getFullYear();
            var startYear = currentYear - 99;
            var endYear = currentYear - 10;
            var dateRange = '"'+startYear+' : '+endYear+'"';

            // Replace "billing_date_of_birth" with the ID or name of your date of birth field
            $('#billing_date_of_birth').datepicker('option', {
                yearRange: dateRange
            });
        });
    </script>
    <?php
}
add_action('wp_footer', 'extend_date_of_birth_range');
?>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template