Hello RsForm(ers)
I´m using a multipage form to sell 1 product (something like a citypass) usign Authorize.net plugin. There is a field where the user should type in a discount code, and I need to:
1st PAGE OF FORM
Initial price is set to $10 (this is fixed, only one product)
1- Validate that the code exist (this is done, the codes and it´s values where inserted using another RsForm Pro form, that´s working correctly)
2- Validate that the code is not a Redeem Code Type (this is done)
3- Capture and post the value of the discount to the form (this is done)
4- Assign that value to a Donation field (this field is on the 2nd page of the form) and perform the calculation of the total price (this is another field, also in the 2nd page). I´ll use the donation field with a negative value to perform a substraction from the price. This should be done by pressing a button before going to the second page
2nd PAGE OF FORM
1- Show the result of the calculations (InicialPrice - Discount = TotalPrice) before proceeding to 3rd page
3rd PAGE OF FORM
1- input credit card information and pay (done)
Now, the problem is on step 4 of the first page. Below I paste the code of the function I´m using in the customvalidation.php file.
Any help would be much apreciated
public static function validationCupon2($value, $extra = null, $data = null)
{
$form = JFactory::getApplication()->input->get('form', array(), 'array');
$db = JFactory::getDBO();
$db->setQuery("select SubmissionId From s0nc1t_rsform_submission_values where FormId = 13 and FieldName = 'Code' and FieldValue ='".$value."' LIMIT 1");
$SubmissionId = $db->loadResult();
if ($SubmissionId == 0)
{
$_POST['form']['last_name']="test";
return false;
}
if ($SubmissionId >0)
{
$db->setQuery("select FieldValue From s0nc1t_rsform_submission_values where SubmissionId = '".$SubmissionId."' AND FieldName = 'Type' LIMIT 1");
$tipoDescuento = $db->loadResult();
if ($tipoDescuento != "Redeem")
{
$db->setQuery("select FieldValue From s0nc1t_rsform_submission_values where SubmissionId = '".$SubmissionId."' AND FieldName = 'Discount' LIMIT 1");
$descuento = $db->loadResult();
if ($descuento >0)
{
$_POST['form']['pay_desc']=$descuento; //this is working correctly. it asigns the value to the field, but only when form is submitted after the last step. i can see the value in the list of submissions.
var_dump($SubmissionId);exit; //this shows the real value of the discount at the end
return true;
// asign value to donation field to calculate total price after the first step is validated and before submitting the form. this is WHAT I NEED
}
}
}
}