• 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: Coupon code field for paypal payments

Coupon code field for paypal payments 10 years 2 months ago #26288

  • munklunk99
  • munklunk99's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 2
  • Thank you received: 1
How can I create a coupon field? I have entered the following into the called on form process php section to no avail.
if($_POST['form']['discount'] == 'coupon')
 $_POST['form']['total'] = $_POST['form']['total'] - 5;

Any help would be greatly appreciated.
The administrator has disabled public write access.

Coupon code field for paypal payments 10 years 2 months ago #26294

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

If you are using the payment plugin available for the component, then please note that the total cost of the transaction is stored in a hidden field named 'rsfp_Total'. In order to apply a discount for this total you could try using the following code:

if($_POST == 'coupon')
$_POST = $_POST - 5;
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.
The following user(s) said Thank You: munklunk99

Coupon code field for paypal payments 10 years 2 months ago #26304

  • munklunk99
  • munklunk99's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 2
  • Thank you received: 1
Here is the correct code of anyone who needs it
$amount=$_POST['form']['rsfp_Total']; 
if($_POST['form']['your_coupon_field_name'] == 'your_coupon_field_code')
   $_POST['form']['rsfp_Total'] = $amount - your_amount;

this needs to be placed in "Script called on form process"
Last Edit: 10 years 2 months ago by munklunk99.
The administrator has disabled public write access.
The following user(s) said Thank You: nohud

Coupon code field for paypal payments 9 years 5 months ago #29502

  • sales447
  • sales447's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 3
Just what I need by the sounds of it, but could you please give a step by step on how to implement the code please.

I have created a form using RSForms;
strictlyoldskool.net/index.php?option=com_rsform&formId=9

I just want to add a simple coupon field that when a user enters "#RCFF" or "Musicmondays" a 10% discount is deducted from the total amount.
I purchased RSEvents thinking that I could utilise the coupon component with the integration plugin, but this is not ideal due to having to recreate the form using RSEvents, and house if you will RSForms information in it, I wanted to do it the other way round, So a no goer on that one.

So I have put this in the "script" tags and place it directly in the bottom of my RSForm; But I am struggling to make it function. Could anyone please advise.
$amount=$_POST['form']['rsfp_Total']; 
if($_POST['form']['your_coupon_field_name'] == 'your_coupon_field_code')
   $_POST['form']['rsfp_Total'] = $amount - your_amount;


Is this right?
$amount=$_POST['form']['rsfp_Total']; 
if($_POST['form']['form[RSEProCoupon]'] == 'Musicmondays')
   $_POST['form']['rsfp_Total'] = $amount - -10%;

I cant get it to work
Last Edit: 9 years 5 months ago by sales447.
The administrator has disabled public write access.

Coupon code field for paypal payments 9 years 5 months ago #29513

  • cosmin.cristea
  • cosmin.cristea's Avatar
  • OFFLINE
  • Platinum Boarder
  • Posts: 756
  • Thank you received: 144
This doesn't need to be inserted in the form, you will have to use the specific PHP scripting area. Click Form Properties > PHP scripts and in the second textbox (Scripts called on form process), insert this:
$amount=$_POST['form']['rsfp_Total']; 
if($_POST['form']['form[RSEProCoupon]'] == 'Musicmondays')
   $_POST['form']['rsfp_Total'] = $amount - 10%;

Also, please keep in mind that your code had the "-" twice.

More information on PHP scripts can be found here:
www.rsjoomla.com/support/documentation/v...602-php-scripts.html


PS: don't use the PHP tags in the scripting areas
My help is not official customer support. To receive your support, submit a ticket by clicking here
The administrator has disabled public write access.

Coupon code field for paypal payments 9 years 3 weeks ago #30908

  • iLLeT
  • iLLeT's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 5
Hi, This works except when a user hits the submit button without filling in the required fields. I get

Parse error: syntax error, unexpected ';' in /home/root/public_html/domain.com/administrator/components/com_rsform/helpers/rsform.php(2106) : eval()'d code on line 3
Last Edit: 9 years 3 weeks ago by iLLeT.
The administrator has disabled public write access.

Coupon code field for paypal payments 8 years 4 months ago #33232

  • martc
  • martc's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 1
Did have any luck with this code myself, used the below to work out a percentage discount (0.1 = 10%)
$amount=$_POST['form']['rsfp_Total']; 
if($_POST['form']['discount'] == 'XMAS')
   $_POST['form']['rsfp_Total'] = $amount - ($amount * 0.1);
The administrator has disabled public write access.

Coupon code field for paypal payments 8 years 4 months ago #33384

  • cosmin.cristea
  • cosmin.cristea's Avatar
  • OFFLINE
  • Platinum Boarder
  • Posts: 756
  • Thank you received: 144
The script provided above is an example, it should be thoroughly tested and adapted to your scenario, as an alternative you could try using a script like the one below:
if ($_POST['form']['radio'] == 'some-choice'){
  $paypal = RSFormProPayPal::getInstance();
  $paypal->args['discount_rate'] = 50;
}
My help is not official customer support. To receive your support, submit a ticket by clicking here
The administrator has disabled public write access.

Coupon code field for paypal payments 7 years 1 month ago #36600

  • paul55
  • paul55's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 5
I have tried all the variations shown above and cannot get this script to work. Has anyone actually got it to function at all? While it would be nice if it adjusted the total on the form I'd be happy with it adjusting the amount when going to PayPal. Here are the three scripts I've tried:

https://photos.google.com/album/AF1QipPwuqiZAW2KlQEItQMPEJC7NbjAGTbjig9vRS4z


I don't get an error on the form.
Last Edit: 7 years 1 month ago by paul55.
The administrator has disabled public write access.

Coupon code field for paypal payments 7 years 1 month ago #36601

  • info7163
  • info7163's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 1
But what if i need to generate a 400 unique discount codes and also to check if code was used before. Is there a possibility to do that?
The administrator has disabled public write access.

Coupon code field for paypal payments 7 years 1 month ago #36624

  • paul55
  • paul55's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 5
Although this is a very old thread I thought I'd post the RSFormsPro solution that worked for us —just in case anyone else can use it. As you can see it's slightly different from the posted solutions:

$amount = $_POST['form']['rsfp_Total']; 
if ($_POST['form’][‘your_coupon_field_name’] == ‘your_coupon_field_code’){
  $paypal = RSFormProPayPal::getInstance();
  $paypal->args['discount_rate'] = 10;
}

Note that you need to modify it in 3 places to suit your form. The value 10 calculates a 10% discount
Last Edit: 7 years 1 month ago by paul55.
The administrator has disabled public write access.

Coupon code field for paypal payments 6 years 11 months ago #36930

  • carlfarring
  • carlfarring's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 3
  • Thank you received: 1
I am currently using stripe for payment process. Can you post the three locations, much appreciate.
Last Edit: 6 years 11 months ago by carlfarring. Reason: Quick mod
The administrator has disabled public write access.

Coupon code field for paypal payments 6 years 6 months ago #37444

Just in case someone needs an update on this using an amount rather then a percentage.
dollar discount example
$amount = $_POST['form']['rsfp_Total']; 
if ($_POST['form’][‘your_coupon_field_name’] == ‘your_coupon_field_code’){
  $paypal = RSFormProPayPal::getInstance();
  $paypal->args['discount_amount'] = 10;
}

And in response to carlfarring, the three locations you change are:
"your_coupon_field_name" - create a textbox and set the name to the same as this
"your_coupon_field_code" - whatever you want your coupon code to be
"10" - what you want your discount to be

to change to a percentage
Switch
$paypal->args['discount_amount']

with
$paypal->args['discount_rate']
Last Edit: 6 years 6 months ago by richard.bankert.
The administrator has disabled public write access.
The following user(s) said Thank You: RPPEO, ccarter
  • 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!