1

I have a RSform!Pro which is working great except for... I need to apply a 50% discount if people select a certain option in a radio button group. I'm using a code that should work as I found it in RSJoomla forum and they say it works. But not for me:

$amount=$_POST['form']['rsfp_Total']; 
if($_POST['form']['form[my_radio_button_group]'] == 'option 1')
   $_POST['form']['rsfp_Total'] = $amount - 50%;

I also tried this, but nothing still...

if($_POST['form']['form[form[my_radio_button_group]'] == 'option 1')
  $_POST['form']['form[Total]'] = $_POST['form']['form[Total]'] - 50%;

Any help?

Toto
  • 89,455
  • 62
  • 89
  • 125

2 Answers2

0

You cant subtract with 50%. Try this:

if($_POST['form']['form[form[my_radio_button_group]'] == 'option 1') {
  $var = $_POST['form']['form[Total]'];
  $half = ((float) $var)/2;
  $_POST['form']['form[Total]'] = $half;
}
Burning Crystals
  • 1,157
  • 3
  • 19
  • 35
0

The $_POST variables can be accessed like this:

$_POST['form']['name_of_field']

Basically, you can 'hack' the rsfp_total as you described :

if ($_POST['form']['radio'] == 'some-choice'){
    $_POST['form']['rsfp_Total'] = $_POST['form']['rsfp_Total'] / 2;
}

Or you can send a new argument to paypal like this (the correct way):

if ($_POST['form']['radio'] == 'some-choice'){
  $paypal = RSFormProPayPal::getInstance();
  $paypal->args['discount_rate'] = 50;
}

You can find more information on this here: https://goo.gl/vi6BPd

Cosmin
  • 49
  • 1
  • 3