• Resolved Artur Le?niewski

    (@arturlesniewski)


    Hey, I have a problem and I am asking for help. I want to use Product Input Fields and exactly the datepicker. I want to display inline, without displaying the input I want to see the calendar right away.

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi,

    Unfortunately that’s not possible yet but we have added it to our todo list.

    Thread Starter Artur Le?niewski

    (@arturlesniewski)

    I add this code in functions.php

    add_action( 'wp_enqueue_scripts', 'load_theme_scripts' );
    
    function load_theme_scripts() {
        global $wp_scripts; 
        $wp_scripts->registered[ 'wcj-datepicker' ]->src = get_template_directory_uri() . '/woocommerce-jetpack/includes/js/wcj-datepicker.js';
    }

    I’ve overwritten the file

    /**
     * wcj-datepicker.
     *
     * @version 3.0.0
     * @todo    maybe_exclude_dates: <code>date.getDate()</code>, <code>date.getFullYear()</code>
     * @see     maybe_exclude_dates: https://stackoverflow.com/questions/501943/can-the-jquery-ui-datepicker-be-made-to-disable-saturdays-and-sundays-and-holid
     */
    
    jQuery(document).ready(function() {  
    	jQuery("input[display='date']").each( function () {
                
                     var datePickerInline = jQuery(this).parent().append('<div/>');
                     
                     
    		var mindate = jQuery(this).attr("mindate");
    		if (mindate === 'zero') {
    			mindate = 0;
    		}
    		var maxdate = jQuery(this).attr("maxdate");
    		if (maxdate === 'zero') {
    			maxdate = 0;
    		}
                    
                    jQuery(this).hide();
                    
                    datePickerInline.datepicker({
                        inline: true,
                        dateFormat : jQuery(this).attr("dateformat"),
                        minDate : mindate,
                        maxDate : maxdate,
                        firstDay : jQuery(this).attr("firstday"),
                        changeYear: jQuery(this).attr("changeyear"),
                        yearRange: jQuery(this).attr("yearrange"),
                        beforeShowDay: maybe_exclude_dates,
                        altField: '#'+jQuery(this).attr('id'),
                        dayNamesMin: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]
                    });
    
                    jQuery('#'+jQuery(this).attr('id')).change(function(){
                        datePickerInline.datepicker('setDate', $(this).val());
                    });
                                
                    
    		function maybe_exclude_dates(date){
    			var exclude_days = jQuery(this).attr("excludedays");
    			if (typeof exclude_days !== typeof undefined && exclude_days !== false) {
    				var day = date.getDay();
    				for (var i = 0; i < exclude_days.length; i++) {
    					if (day == exclude_days[i]) {
    						return [false];
    					}
    				}
    			}
    			var exclude_months = jQuery(this).attr("excludemonths");
    			if (typeof exclude_months !== typeof undefined && exclude_months !== false) {
    				var month = date.getMonth() + 1;
    				for (var i = 0; i < exclude_months.length; i++) {
    					if (month == exclude_months[i]) {
    						return [false];
    					}
    				}
    			}
    			return [true];
    		}
    	});
    });
    
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Product input fields – datepicker display inline’ is closed to new replies.