Jul 5th, 2010, 5:32 PM
(This post was last modified: Jul 5th, 2010, 5:33 PM by michael.ka.)
(I don’t know about the details of making PayPal work with Form Tools so I’m going to assume that you are correct and that it is indeed necessary to submit an 'amount' in order to make PayPal work.)
The Submission Pre-Parser module should be able to solve your problem. It allows you (among other things) to combine fields.
Here is the example code for combining fields:
The Submission Pre-Parser module should be able to solve your problem. It allows you (among other things) to combine fields.
Here is the example code for combining fields:
PHP Code:
<?php
if ( (isset($_POST["phone_1"]) && !empty($_POST["phone_1"])) &&
(isset($_POST["phone_2"]) && !empty($_POST["phone_2"])) &&
(isset($_POST["phone_3"]) && !empty($_POST["phone_3"])) )
{
$_POST["phone"] = "{$_POST["phone_1"]}-{$_POST["phone_2"]}-{$_POST["phone_3"]}";
}
All this does is check whether the three submitted input fields with the names 'phone_1', 'phone_2' and 'phone_3' are set and not empty (first three lines) and if that is the case it combines them and submits them with the name 'phone' (last line).
Just change 'phone_1', 'phone_2', 'phone_3' and 'phone' to 'session1', 'session2', 'donate' and 'amount' respectively and you are already halfway there. In this example, however, strings are combined. You don’t want to do that, you want to convert strings to numbers and add them together. You might also want to perform some sanity checks, probably different sanity checks than in this case (if one of the values in this example isn’t set, 'phone' just isn’t submitted. In your case 'amount' wouldn’t be submitted which would mean that PayPal doesn’t get the value).
Now, I don’ know PHP, so I can’t tell you with authority about the details of making this work. It should amount to some fairly trivial PHP code. Google tells me that converting a string to integer works something like this:
PHP Code:
<?php
settype($foo, "integer");
