Ciao ragazzi. Ho bisogno di realizzare un'automazione in Wordpress. Vorrei che sul "submit" di un form CF7 venga silenziosamente eseguito uno script JS/JQuery per bookare un appuntamento sulla piattaforma Teamup Calendar, "prelevando" i dati dagli id del form.
Qualcosa del tipo (esempio errato/incompleto):
Ora queste sono le questioni:
Qualcosa del tipo (esempio errato/incompleto):
Codice:
var CALENDAR_KEY = 'key';
var SUBCALENDAR_ID = 'id';
var API_KEY = 'api-key';
$(document).addEventListener( 'wpcf7submit', function( event ) {
// Declare the variables we want to get from the form
// var name = "no-name"; // Default to "no-name" and "no-subject"
// var subject = "no-subject";
var ragionesociale;
var telefono;
var indirizzo;
var citta;
var provincia;
var CAP;
var operatore;
var agente;
var datapp;
var orapp;
var noteapp;
// Loop through the inputs of the Contact Form and store them in the variable above.
var inputs = event.detail.inputs;
for (var i = 0; i < inputs.length; i++) {
if ('your-name' == inputs[i].name) {
name = inputs[i].value;
} else if ('your-subject' == inputs[i].name) {
subject = inputs[i].value;
}
}
// Make call to Teamup API
$.ajax({
url: "https://api.teamup.com/" + CALENDAR_KEY + "/events",
type: 'post',
headers: {
"Teamup-Token": API_KEY
},
data: // Edit this line and add in data using the variables above.
"subcalendar_id": SUBCALENDAR_ID,
"start_dt": "2017-03-23T08:00:00-0400",
"end_dt": "2017-03-23T09:00:00-0400",
"all_day": false,
"rrule": "",
"title": ragionesociale,
"who": operatore,
"location": indirizzo +" "+citta+" "+CAP,
"notes": telefono+"<br />"+ragionesociale+"<br /><br />"+noteapp
});
}, false );
Ora queste sono le questioni:
- Per integrare il codice è sufficiente riportarlo nelle impostazioni aggiuntive di CF7?
- La voce subcalendar-id deve essere codificata (ad.ec agente1 diventa "12345").
- La voce location deve essere la risultante di 3 diversi "name/id" provenienti dal form
- start-dt: codificare la data in questo formato 2017-10-10T10:00:00-0400 partendo da un semplice 10/10/2017 e 10:00.
- Iniettare tutto questo tramite api.