Skip Navigation

[Résolu] Customized Date Formatting Not Working & Email not Sending

This support ticket is created Il y a 5 années et 1 mois. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

Marqué : 

This topic contains 9 réponses, has 2 voix.

Last updated by Luo Yang Il y a 5 années et 1 mois.

Assisted by: Luo Yang.

Auteur
Publications
#1212297

Hey Guys

Ok so this is regarding more than one issue. So please let me know if I am a bit all over the place...

1. I am trying to change the date selectors in a form to block certain dates depending on existing bookings, and not allowing them to choose dates before today.
In my functions.php file, i added a shortcode which handles that, the specific code is line 153-180 (code currently commented out, Please feel free to enable again).

If I uncomment the code, when I try to submit the booking on equipment, it tells me the date fields are empty when they are not. Which means the value must somehow become lost when I change it...

Please assist if possible...

2. When I do submit the booking form (if the above issue is bypassed), the form is not emailed to me. So I am assuming I may be miss-understanding the variables usage in it. Would you be able to advise if I am using it correctly?

#1212328

Hey Guys,

I moved the code from the functions file to the code snippets in Toolset->Settings->Custom Code->item-available-from-date
Hope that makes it a bit easier 🙂

#1212498

Hello,

Q1) I am trying to change the date selectors in a form to block certain dates depending on existing bookings, and not allowing them to choose dates before today...

It is a custom codes problem, according to our support policy, we don't provide custom codes support.

Here are my suggestion: in Toolset forms, the datepicker instance has already been initiated when you load the page, so you don't need to create new datepicker instance, you can change the existed datepicker options(minDate), like this:

jQuery(document).on('cred_form_ready', function() {
	jQuery('.js-wpt-date[name^=\"wpcf-end-date\"]').datepicker('option', 'minDate', 0);
	jQuery('.js-wpt-date[name^=\"wpcf-starting-date\"]').datepicker('option', 'minDate', 0);
});

You can disable your custom codes, test above codes directly:
edit post form "Submit Booking", click "JS editor", copy/paste above JS codes, and test again.

More help:
hidden link
see "Code examples" in above document

Q2) When I do submit the booking form (if the above issue is bypassed), the form is not emailed to me.
I assume we are talking about the same post form, the notification settings "Booking Request Submitted", in option "Send notification to a specific email address", you are using custom shortcode:
[get_parent_email post_id='[wpv-post-id]']

That option does not support custom shortcode, in your case, I suggest you setup custom codes using filter hook "cred_notification_recipients", see our document:
https://toolset.com/documentation/programmer-reference/cred-api/#cred_notification_recipients
You can get the example codes by clicking "Usage examples"

#1212548

Ok but the question remains though, how will I be able to block out the other dates then as I am able to do now?
I am assuming I need to change the rest of my jquery code to block out specific dates... But what do I need to change?

#1212807

Hey guys,

When I added the code as you suggestion, using the existing options flag, if I am submitting a booking from hidden link I still get an error message on the form submit, Can you please urgently help me get it sorted?

#1212875

Have you tried as I mentioned above?
https://toolset.com/forums/topic/customized-date-formatting-not-working-email-not-sending/#post-1212498

You can disable your custom codes, test above codes directly:
edit post form "Submit Booking", click "JS editor", copy/paste above JS codes, and test again.

I have tried it in your test site:
1) Dashboard-> Toolset-> Settings-> Custom Code
click "Custom Code", deactivate your custom code "item-available-from-date "
2) add the same JS codes into the post form "Submit Booking":

jQuery(document).on('cred_form_ready', function() {
    jQuery('.js-wpt-date[name^=\"wpcf-end-date\"]').datepicker('option', 'minDate', 0);
    jQuery('.js-wpt-date[name^=\"wpcf-starting-date\"]').datepicker('option', 'minDate', 0);
});

Test it in front-end:
hidden link

It works fine, can you confirm it?

So there should be some PHP errors in your custom codes, according to our support policy, we don't provide custom codes support:
https://toolset.com/toolset-support-policy/

You can debug your custom codes manually line by line, you can also check it with our Toolset Contractors:
https://toolset.com/contractors/

#1212946

Hey Guys,

Looks like it is the JS causing it... But now the question is, how can I change the dates you output in the date picker then?
Is there some sort of hook or something?

Essentially I just need to be able to disable a bunch of dates I get in PHP, so people can't click them....
I was using
jQuery(document).on('cred_form_ready', function() {
jQuery('.js-wpt-date[name^=\"wpcf-end-date\"]').datepicker('option', 'minDate', 0);
jQuery('.js-wpt-date[name^=\"wpcf-starting-date\"]').datepicker('option', 'minDate', 0);

jQuery('.js-wpt-date[name^=\"wpcf-end-date\"]').datepicker( 'option', 'beforeShowDay', get_available_dates);
jQuery('.js-wpt-date[name^=\"wpcf-starting-date\"]').datepicker( 'option', 'beforeShowDay', get_available_dates);
});

Which obviously has it's flaws, so question is how can I control the dates?

#1212954

No, as you can see, there isn't such a built-in feature within Toolset Forms plugin, it needs custom codes, and I have already provided a demo JS codes for you.

For the datepicker option "beforeShowDay", please check Jquery document:
hidden link

For your reference.

You can also add a feature request for it:
https://toolset.com/home/contact-us/suggest-a-new-feature-for-toolset/

#1212971

Ok I understand... How about this though...
Where can I define a javascript variable so that the toolset form template where the JS now is, will see the variable?
Obviously I need to define the variable ahead of time, which means that I need to bind it to an event that fires before the JS you provided?

#1212978

To define a JS variable, please check document:
hidden link

To define a JS variable in Toolset form, you can put the JS codes insider form content, like this:

<script>
var carName = "Volvo";
  console.log(carName);
</script>

See the example codes of above document, section "Declaring (Creating) JavaScript Variables"

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.