Forums

Question on OnSubmit and Redirect

mendel 19 Sep, 2010
Hi! Although this is my first post, trust me, I've read just about this entire forum. Exaggeration aside, I have a couple of questions:

1) I'm building a form which redirects to Paypal (using the plugin). I have a radio list ending with an "other", followed by a text box. I used the following PHP in the OnSubmit box to update the hidden input going to Paypal:

$totalamount = JRequest::getInt('amount', 0, 'post') + JRequest::getInt('otherChoice', 0, 'post');
JRequest::setVar('totalamount', $totalamount);
.
For some reason, although the "totalamount" in my email comes out correctly, The URL being output to Paypal does NOT inclue the figure in "totalamount".

Any ideas why?

2) I have a second radio list. I'd like to have that if a certain one is selected, the form does NOT redirect to Paypal, but instead just displays a message. This is what I've come up with so far (for my OnSubmit box):

if(JRequest::getVar('paymentmethod') != 'PayPal'){
    $MyForm->setFormData('redirecturl', 'THIS IS MY QUESTION!');
    }


Any help would be greatly appreciated 🙂
Max_admin 20 Sep, 2010
Hi mendel,

#1- I will assume you are using the "Redirect" plugin ? make sure the flow control is set to "After email" and add your code in the "Extra before CURL code" under "Extra code" tab, all in the plugin's config page

#2- you may disable the plugins through a piece of code, use this code in the "before email" code box as long as you have at least 1 email enabled:


<?php
$MyForm =& CFChronoForm::getInstance('FORM NAME HERE');
$MyForm->setFormParam('plugins', '');
?>


Cheers,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
mendel 21 Sep, 2010
#1 - Bingo! Right on. Thanks a ton.

#2 - It didn't work for me. I put it into the "On Submit code - before sending email" box. First I tried to do filtered by the radio selection:


<?php
if(JRequest::getVar('paymentmethod') != 'PayPal'){
    $MyForm =& CFChronoForm::getInstance('ChronoContact_Main_ST2');
    $MyForm->setFormParam('plugins', '');
    }

?>


That didn't work. So then I just put it straight up:


<?php
$MyForm =& CFChronoForm::getInstance('ChronoContact_Main_ST2');
$MyForm->setFormParam('plugins', '');
?>


Also didn't work. Any idea what I'm doing wrong?

I do have an email template, and its enabled, in case you were wondering.

Thank you for your help.
mendel 26 Sep, 2010
Don't mean to bump, but I need this information. Can anyone here help me with this? :?
GreyHead 26 Sep, 2010
Hi mendel,

Try Max's code again but use just Main_ST2 as the form name (the prefix is probably not needed.

Or use this code to get the form name automatically:
$formname =& JRequest::getString('chronoformname', '', 'get');


Bob
mendel 26 Sep, 2010
I tried again without the prefix. Still no luck 😢 .

I wasn't sure how to implement the code to get the form name automatically, so I just echoed it, then copied the results (Main_ST2) into my previous code. Still no luck. What am I doing wrong?
GreyHead 28 Sep, 2010
Hi mendel,

Hmm . . . thre is no good way of stopping a Plug-in that I know of :-)

Maybe just brute force. Make sure that the Plug-in is set after everything else you need to run. Then redirect from the OnSubmit After box
<?php
$pay_method = JRequest::getString('paymentmethod', '', 'post');
if( $pay_method != 'PayPal'){
    $mainframe->redirect('redirecturl', 'THIS IS MY QUESTION!');
}
?>


Bob
This topic is locked and no more replies can be posted.