Datepicker question… 7 day buffer?
-
Is it possible to set this up so a person couldn’t pick the next 7 days, but rather could only select dates that were 7 days (or other custom number) out from the current date?
-
Just to clarify this, I’m wondering if it’s possible to disallow the next X days, similar to the current functionality of allow the next X days.
I found a way to add this functionality to the plugin, and also make it so the “disallowed” date range can be easily added in the field setting, just like for the “Allow the next X days” functionality.
In order to make it work and to add the the admin capability, I edited wcff-builder.php and wcff-meta.php. I’d be happy to provide the edited files to the plugin developer and maybe you could add this to an updated version of the plugin?
Let me know if you’re interested. The edits to the two files are fairly minor and easy to implement.
@djenk That would be nice, please post your changes here, I will make sure to add with my upcoming release.
Also I am glad that you found the plugin flow and code structure easy enough to add your custom feature 🙂
-
This reply was modified 8 years, 6 months ago by
Saravana Kumar K.
Here are the changes. Hopefully this format makes sense.
includes > wcff-builder.php
line 1599 :::: this line was added
isset($_field[“disallow_next_x_days”]) && !empty($_field[“disallow_next_x_days”])
line 1613 :::: this line was added
if (isset($_field[“disallow_next_x_days”]) && !empty($_field[“disallow_next_x_days”]) && is_numeric($_field[“disallow_next_x_days”])) {
$disallowed_dates .= “+”. trim($_field[“disallow_next_x_days”]) .”d”;
}line 1616 :::: edited to: (this line might unfortunately make the allow dates not work but this could be made into if/then)
echo “,minDate: 0+\””. trim($disallowed_dates) .”\””;
includes > meta > wcff-meta.php
line 1171 :::: this array was added: (adds Admin functionality in backend)
array(
“header” => array(
“title” => __(‘Disallow X Days’, ‘wc-fields-factory’),
“target” => “#wcff-date-field-disallow-only-next-x-days”,
“css_class” => “”
),
“content” => array(
“container” => “wcff-date-field-disallow-only-next-x-days”,
“fields” => array(
array(
“type” => “number”,
“param” => “disallow_next_x_days”,
“placeholder” => __(‘Disallow only next X days from the current date’, ‘wc-fields-factory’),
“min” => “1”,
“step” => “1”,
“at_startup” => “show”,
“translatable” => “no”
)
)
)@djenk thanks, I will include it on the next version.
Hello, I also need the same functionality. Could you help me?
I tried to add the code that appears above and the terrible white screen appeared…
Can you help me (Please!)?Here’s a link to the two modified files. Maybe try and use these?
https://www.dropbox.com/sh/hsp4e0slvj92p66/AABeffe0JjMVHv8zIV4pxceua?dl=0
Ok, thank you very much, it’s exactly what I was looking for and it works!
Just wondering if the latest version of the plugin has included this ability to disallow certain number of days. I’d like to update the plugin but will lose my customizations, or will need to add them to the updated version.
Thanks!
-
This reply was modified 8 years, 6 months ago by
The topic ‘Datepicker question… 7 day buffer?’ is closed to new replies.