Hey all,
I was just transferring some custom javascript over to chronoforms when I found I needed a dynamic redirect field instead of the 'static' one provided on the control panel.
So I did a minor hack to /components/com_chronocontact/chronocontact.php that I thought I'd share.
In my case, I wanted a dynamic redirect field (i.e. "How do you want to pay? <select name="payment_type" onchange="resetRedirect(this.form)" ><option value="Paypal">Paypal</option><option selected value="check">check</option>" and depending on the answer, the redirect is to the check URL or the paypal URL).
Solution
to FormHTM:
I added a hidden field called redirect
(where http://mysite.com/thankyou_check.html is now the default to match the selected option value above.
to /components/com_chronocontact/chronocontact.php:
I changed the following section:
to read:
to FormJavaScript:
I added something like
I figure you can do similar hacks to other Chrono fields. Hope this helps some similar situations out there.
STEVE
I was just transferring some custom javascript over to chronoforms when I found I needed a dynamic redirect field instead of the 'static' one provided on the control panel.
So I did a minor hack to /components/com_chronocontact/chronocontact.php that I thought I'd share.
In my case, I wanted a dynamic redirect field (i.e. "How do you want to pay? <select name="payment_type" onchange="resetRedirect(this.form)" ><option value="Paypal">Paypal</option><option selected value="check">check</option>" and depending on the answer, the redirect is to the check URL or the paypal URL).
Solution
to FormHTM:
I added a hidden field called redirect
<input type="hidden" name="redirect" value="http://mysite.com/thankyou_check.html">
(where http://mysite.com/thankyou_check.html is now the default to match the selected option value above.
to /components/com_chronocontact/chronocontact.php:
I changed the following section:
/**
* Redirect the page if requested
*/
if ( !empty($rows[0]->redirecturl) ) {
mosRedirect($rows[0]->redirecturl);
}
to read:
/**
* Redirect the page if requested
*/
if ( !empty($fields['redirect']) ) {
mosRedirect($fields['redirect']);
} else {
if ( !empty($rows[0]->redirecturl) ) {
mosRedirect($rows[0]->redirecturl);
}
}
to FormJavaScript:
I added something like
function resetRedirect {
var paypalUrl = 'https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=info%40mysite.com&item_name=MyItemName&amount=' 100'¤cy_code=USD&return=http://mysite.com/thankyou_paypal.htm;
if (theForm.payment_type.value == "Paypal"«») {
theForm.redirect.value = paypalUrl;
} else {
theForm.redirect.value = "http://mysite.com/thankyou_check.htm";
}
}
I figure you can do similar hacks to other Chrono fields. Hope this helps some similar situations out there.
STEVE
Hi Spaceman,
Thanks very much for sharing your hack here with everybody, for those who can't hack the file and prefer to do the same function without the hack, just follow all spaceman steps but instead of hacking the core chronoforms file do this :
At the "on Submit Before email" field, please write this code :
this will override the static value in the CPanel of Chronoforms for the redirectURL😉
Cheers
Max
Thanks very much for sharing your hack here with everybody, for those who can't hack the file and prefer to do the same function without the hack, just follow all spaceman steps but instead of hacking the core chronoforms file do this :
At the "on Submit Before email" field, please write this code :
<?php
$rows[0]->redirecturl = $_POST['redirect'];
?>
this will override the static value in the CPanel of Chronoforms for the redirectURL😉
Cheers
Max
How do you get the status back from paypal and either go to an error page or a thank-you page?
Hi julieh,
You can use the PayPal return, and cancel_return parameters to get information back from PayPal. If you use IPN you can also use the notify_url parameter.
You need to check the PayPal docs to see exactly what is available.
Bob
You can use the PayPal return, and cancel_return parameters to get information back from PayPal. If you use IPN you can also use the notify_url parameter.
You need to check the PayPal docs to see exactly what is available.
Bob
Hi Spaceman,
Thanks very much for sharing your hack here with everybody, for those who can't hack the file and prefer to do the same function without the hack, just follow all spaceman steps but instead of hacking the core chronoforms file do this :
At the "on Submit Before email" field, please write this code :
<?php
$rows[0]->redirecturl = $_POST['redirect'];
?>
this will override the static value in the CPanel of Chronoforms for the redirectURL😉
Cheers
Max
This code doesn't want to run on the first try though, now's okey. Will move further on..
This topic is locked and no more replies can be posted.