Using a Pop-up Calendar as a Variation
If you would like to have a pop-up calendar appear when a date field variation is clicked, here is some sample code to get you started. Put this code in your functions.php file and then put this code in your foxyshop-single-product.php file before the end of the form. You may want to tweak it a little bit, but this will give you a good head start. Some notes:
- WordPress 3.1+ required. If you can’t do that, you can load in the jQuery UI includes yourself.
- Create variation (single line of text) called “Start Date”
- If you want to set a date range, set custom fields on the product called “minDate” and/or “maxDate”. These values can be a date (m/d/y – must use forward slashes) or it can be a number of days(+1, -20, etc) or, it can be a string (+1M +1D). See the jQuery UI Datepicker documentation for more details. Be default it disables all past dates since FoxyCart will reject a subscription starting in the past anyway.
- If you want to exclude certain dates, make a custom field called excludeDates” and add your comma-separated dates like this: “1/1/2013, 2/13/2013, 9/10/2013”.
- If you want to disable all weekends, uncomment the first two lines in getExcludedDates() and comment the third line.
Posted in: Helpful Code Snippets