• 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!

TOPIC: Making RSForms do different things upon submit

Making RSForms do different things upon submit 12 years 4 months ago #15810

Hi all,
Perhaps this is a simple thing and i just don't get it. I would like a user who fills out a form for my event upon hitting submit be taken to PayPal if he has chosen a "credit" check box, or a thank you page if they have checked "check."
Thank you.
The administrator has disabled public write access.

Re: Making RSForms do different things upon submit 12 years 4 months ago #15821

  • andreic
  • andreic's Avatar
  • OFFLINE
  • RSJoomla! Official Staff
  • Posts: 722
  • Thank you received: 59
Hello,

The RSForm!Pro - PayPal integration uses the standard PayPal website payment method, the customer will be redirected to the Paypal page when the form is submitted where he will need to log in to his PayPal account and manually approve the transaction. This integration will redirect the user to the PayPal site each time the form is submitted.

In order to allow the user to choose either a check or online payment and only redirect the user to PayPal when the online payment option is selected you will need some custom scripting. You will need to add a radio group to the form where the user will choose this payment method and if he chooses to pay through PayPal, send the transaction information to the payment gateway through a custom script. An example on this topic can be found here:

demo.rsjoomla.com/custom-paypal-form-example
Please note: my help is not official customer support. To receive your support, submit a ticket by clicking here
Regards,
RSJoomla! Development Team
The administrator has disabled public write access.

Re: Making RSForms do different things upon submit 12 years 4 months ago #15827

Hi
Ok so I see how the form is created with custom scripting and i see how the script
if($_POST != '0')
{
$business = ' This e-mail address is being protected from spambots. You need JavaScript enabled to view it ';
$item_name = 'Products';
$currency_code = 'USD';
$amount = $_POST;
$return = 'http://your_site.com';
header('Location: www.paypal.com/cgi-bin/webscr?cmd=_xclic...t.'&return='.$return); exit();
}

goes in the script after form area. But what script would I put in the attributes area of the radio group to only direct those who select paypal there?
thanks
The administrator has disabled public write access.

Re: Making RSForms do different things upon submit 12 years 4 months ago #15875

  • learnthrusong
  • learnthrusong's Avatar
  • OFFLINE
  • Junior Boarder
  • Posts: 26
  • Thank you received: 3
Hi there,

You basically need an if/else block to determine what happens if credit card checked or not.
if ($_POST['form']['your_checkbox_field'] == 1){ // Where 1 is the value for credit card
     // Script for credit card transaction here...
}else{
     // Script for other payment options go here
}
This would need to go inside your first if statement that's checking to see if the TOTAL is more than 0 or not. BTW, no need to single quote numeric values... Better not to to maintain numeric data type for numeric values for database insertion and so on...

If you still need help on this, shout back and I'll see what I can do!

Best wishes,

Gez
The administrator has disabled public write access.

Re: Making RSForms do different things upon submit 12 years 4 months ago #15876

  • learnthrusong
  • learnthrusong's Avatar
  • OFFLINE
  • Junior Boarder
  • Posts: 26
  • Thank you received: 3
One thing i noticed actually...

In the script you posted, you don't seem to set your $vars = to their $_POST[$vars] equivalents...

Was this intentional? Is this working or did you only post the 'shell' to demonstrate how/where you were going to add a script and to give a general overview of what you wanted to achieve? OR

Have you already initialised the $vars with their $_POST values, but wanted to cut down the amount of script you posted?

If the latter, you're form processing script should work with the internal if/else I sent.

Otherwise, your processing shouldn't be working???

If you haven't got it working, a combination of the if/else I posted + the forum link I put into my first post should do the trick. The script in the link (3 or 4 lines) can be used "as is" on any form. It will automatically create a $name_of_field = to every $_POST[$name_of_field] value, i.e. if you have fields; id, name, date etc... (In your case) If your TOTAL was not 0, then it would grab all of the fields' $_POST values as $id, $name, $date etc...

Hope this helps somehow,

Regards,

Gez
Last Edit: 12 years 4 months ago by learnthrusong.
The administrator has disabled public write access.

Re: Making RSForms do different things upon submit 12 years 4 months ago #15884

Hi learnthrusong,
Thank you for getting back to me. I appreciate your help. The script I posted was simply cut and pasted from the RSJoomla site for the question. I have not done any scripting in my form, and have very little experience doing so. Right now my form simply has a radio button for the user to choose credit or check.
For those who choose credit I would like to take them to PayPal on submit, for those who choose check, I want to send them to the thank you mail your check here page.

So I need to know where the script you mentioned goes, and then where does that other script go?

Thanks
The administrator has disabled public write access.

Re: Making RSForms do different things upon submit 12 years 3 months ago #15889

  • learnthrusong
  • learnthrusong's Avatar
  • OFFLINE
  • Junior Boarder
  • Posts: 26
  • Thank you received: 3
Hi there,

Sure, I can definitely help you out on this... You need to go into the script called on form process textarea (PHP Scripts) to place this script. The If/Else block that I sent you would go inside of your existing if(total!= 0) like...
// If the total is greater than 0 (I.E. if there's something in the cart)
if($_POST['form']['Total'] != 0){
	// Now we've checked to see if there is something in the cart, lets check which method of payment they chose
	if ($_POST['form']['your_radio_field'] == 1){ // Where 1 is the value for credit card
		// Now set up variables to use...
		$business = 'me@mybusiness.com'; // Presumeably this will not change so you could put your email here unless you want it dynamic (multiple sellers)
		$item_name = 'Products'; // Presumeably 
		$currency_code = 'USD';
		$amount = $_POST['form']['Total']; // make sure that you have a field with ID Total for this to work
		$return = 'your_site.com'; // Change this to the page you want them to be returned to from PayPay completion
		header('Location: www.paypal.com/cgi-bin/webscr?cmd=_xclick&business='.$business.'&item_name='.$item_name.'¤cy_code='.$currency_code.'&amount='.$amount.'&return='.$return); 
		exit();
	}else{
    	// Script for other payment options go here - maybe insert some info into a transaction or membership table etc...
		// THIS WON'T INTERFERE WITH YOUR EMAILS/so you can still define some email stuff too.
		// This means that if you simply want the form to process normally if NOT paypal, you could delete the "else{ .... }// End non-credit card script" leavint the last "}// End" in
	} // End non-credit card script
}// End 

If you need any more help, please let me know. I may need a bit more info such as...

1 - are you using PayPal integration Plugin for RSForms?
2 - What kind of things are you selling and are they only individual items per transaction?
3 - Do you already have your paypal setup?

Best wishes,

Gez
The administrator has disabled public write access.

Re: Making RSForms do different things upon submit 12 years 3 months ago #15890

  • learnthrusong
  • learnthrusong's Avatar
  • OFFLINE
  • Junior Boarder
  • Posts: 26
  • Thank you received: 3
Sorry,

It would also be highly advisable to put an else statement in where I have "} //END" in order to process submissions that had no total. Otherwise you may get people getting redirected to paypal accidentally!

I think that this works, but been a while since I've tried it, as generally, I'm redirecting people elsewhere as opposed to back to the form but try:
// SO LEAVING THE "} //END", ADD THE FOLLOWING...
else{
return false; // I think this will take you back to the form and highlight any errors on the form
}
DEBUGGING - Checking what you think will be against what is...
A really useful thing to know for debugging is the use of print_r($your_array_var) or echo "$your_var" for select & checkbox fields. This way, you know that what you're expecting to be held in a variable is or not actually there.

Example, if you want to see what the value of the chosen payment option is, if your field was named as mine is in the example, you could do:
//initialise a local variable to reference the field more quickly (if you want to
$payment_method = $_POST['form']['your_radio_field'];
 
// now that the payment method field has been initialised as a 'local' var (i.e. in the current page), 
//we can check it's value by displaying it on the screen
echo "$payment_method"; // this will give you the value of the option.
 
// If you're not getting what you expect, try 'trapping' the 'break-point' in the script by 
// placing die(); statements immediately inside your if/else curly brace "{". 
// Add a unique message to let you know which point in the script you got to like:
 
if (1>2){
  die("Of course 1 is not greater than 2");
}else{
  die("1 is less than 2");
}
// You can also place your variables inside die("$statements"); with or without "quotes".
Hope this helps!!!

Best wishes, Gez
Last Edit: 12 years 3 months ago by learnthrusong.
The administrator has disabled public write access.
The following user(s) said Thank You: stephanietortomasi

Re: Making RSForms do different things upon submit 12 years 3 months ago #15920

  • learnthrusong
  • learnthrusong's Avatar
  • OFFLINE
  • Junior Boarder
  • Posts: 26
  • Thank you received: 3
Hi,

Did you manage to get this working?

Best wishes,

Gez
The administrator has disabled public write access.
  • 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!