• Hi,

    I am attempting to use date data from a Json feed to block out the dates on a Wp Form calendar date picker, as in this example –
    https://wpforms.com/developers/customize-the-date-time-field-date-options/

    Currently I am using the set dates-

    from: “2022-06-10”,
    to: “2022-06-30”

    from: “2022-08-28”,
    to: “2022-09-20″

    I would like to replace these dates with dates I am pulling in from a Json feed.

    The feed is here – https://www.jonnyrossmusic.com/json-test/

    The first date in a row has the handle ‘date” and the second date has the handle ‘endDate’

    The code we have devised is as follows, but this is not working. Please advise if you are able to provide a solution, many thanks.

    
    	
    	<php?
    	function wpf_limit_date_picker() {
     ?>
    	
      <script type="text/javascript">
            fetch('poo.json')
                .then(function (response) {
                    return response.json();
                })
                .then(function (data) {
                    appendData(data);
                })
                .catch(function (err) {
                    console.log('error: ' + err);
                });
    		
    		
    		        function appendData(data) {
                var mainContainer = document.getElementById("myData");
    		
    		        var d = new Date();
            window.wpforms_datepicker = {
                disableMobile: true,
                // Don't allow users to pick specific range of dates
                disable: [
                    {
                       from: + data[i].date,
                        to: + data[i].endDate
                    },
                    {
                        from: "2022-08-28",
                        to: "2022-09-20"
                    }
                ]
            }
    		
    
                for (var i = 0; i < data.length; i++) {
                    var div = document.createElement("div");
                    div.innerHTML = 'date: ' + data[i].date + ' ' + data[i].endDate;
                    mainContainer.appendChild(div);
                }
            }
    		
    		
    		
        </script>
    	
         <?php
    }
    add_action( 'wpforms_wp_footer_end', 'wpf_limit_date_picker', 10 );
    

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

Viewing 1 replies (of 1 total)
  • Hi @rory24884,

    We’d be happy to help!

    It seems that you are using the paid version of WPForms. If you have an active license subscription with us, could you please submit a support ticket through the WPForms account dashboard when you have a chance?

    From there, our support team will be able to take a closer look at your request.

    Thanks!

Viewing 1 replies (of 1 total)
  • The topic ‘Bllocking out dates from calendar using a Json feed’ is closed to new replies.