Title: Discount Code
Last modified: October 2, 2017

---

# Discount Code

 *  Resolved [c0nd3x](https://wordpress.org/support/users/c0nd3x/)
 * (@c0nd3x)
 * [8 years, 7 months ago](https://wordpress.org/support/topic/discount-code-10/)
 * Hello!
 * Some time ago you helped me create a formula to create discount codes that worked
   very well, but in the last update does not work anymore.
 * This is the code:
    (function () {var discount = 0; // Here’s an X saying missing“
   use strict” statement // if ([field_rnField23] == ‘LACA350’) discount = 350; 
   if ([field_rnField23] == ‘LACA600’) discount = 600; return [field_rnField11] –
   discount; } ())
 * Field23 is the id of the field that will hold the coupon code
    Field11 is the
   id of the field that will hold the donation amount Where do I put the field that
   receives the number of people?
 * In the form I have a multiple radio field with two defined prices $ 650 and $
   750 and a field of number of people multiplying the price.
    this code I enter
   it in a field of total of only read and I appear undefined
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fdiscount-code-10%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 6 replies - 1 through 6 (of 6 total)

 *  Plugin Author [EDGARROJAS](https://wordpress.org/support/users/edgarrojas/)
 * (@edgarrojas)
 * [8 years, 7 months ago](https://wordpress.org/support/topic/discount-code-10/#post-9552429)
 * Hello!
 * I just checked your form and it seems that it only has this formula:
 * [field rnField11]*[field rnField12]
 * It doesn’t seems to be using the discount code formula. Coud you check your form
   and make sure the formula is still there please? Or could you send me a link 
   to a form that still has the formula so i can check why is not working anymore(
   you could clone the form and add it to a test page).
 * Regards!
 *  Thread Starter [c0nd3x](https://wordpress.org/support/users/c0nd3x/)
 * (@c0nd3x)
 * [8 years, 7 months ago](https://wordpress.org/support/topic/discount-code-10/#post-9552609)
 * Hello Edgar!
 * this is the new link to the form test
    [https://www.lacaymca.org/yysa2017/prueba/](https://www.lacaymca.org/yysa2017/prueba/)
 * I tryed to do the formula and I put this:
    (function(){var discount=0; if([field_rnField23]
   ==’LACA350′) discount=([field_rnField11]*[field_rnField12])-300; if($$field_rnField23
   $$==’LACA600′) discount=([field_rnField11]*[field_rnField12])-600; return [field_rnField11]*[
   field_rnField12]-discount; }())
 * Field23 is the field that will hold the coupon code
    Field11 is the field that
   will hold the paid amount Field12 is the field that will hold the people amount
 * thank you so much
 *  Plugin Author [EDGARROJAS](https://wordpress.org/support/users/edgarrojas/)
 * (@edgarrojas)
 * [8 years, 7 months ago](https://wordpress.org/support/topic/discount-code-10/#post-9552702)
 * Please try with this formula (which is practically the same but without the first
   and last lines which i think are causing this issue):
 * var discount=0;
    if ([field rnField23] == “LACA350”) discount = 350; if ([field
   rnField23] == “LACA600”) discount = 600; return [field rnField11] – discount;
 * I wasn’t able to test it though since i don’t have a copy of your form but if
   it doesn’t work please let me know and i will check it again.
 * Regards!
 *  Thread Starter [c0nd3x](https://wordpress.org/support/users/c0nd3x/)
 * (@c0nd3x)
 * [8 years, 7 months ago](https://wordpress.org/support/topic/discount-code-10/#post-9552877)
 * Hello!
 * the formula works better, but the discount does not work the way I want.
    I have
   the field of payment and the field number of people these two fields are multiplied
   to give the total and the discount subtracts from the total, I think the formula
   would be like this ((#people*$payment)-discount), but in the form alone take 
   the discount field and do not make the formula. you can see it at [https://www.lacaymca.org/yysa2017/prueba/](https://www.lacaymca.org/yysa2017/prueba/)
 * This is the code I did with your last example
 * var discount=0;
    if([field_rnField23]==’LACA350′) discount= (([field_rnField12]*[
   field_rnField11])-350); if([field_rnField23]==’LACA600′) discount= (([field_rnField11]*[
   field_rnField12])-600); return [field_rnField11]*[field_rnField12]-discount;
 *  Thread Starter [c0nd3x](https://wordpress.org/support/users/c0nd3x/)
 * (@c0nd3x)
 * [8 years, 7 months ago](https://wordpress.org/support/topic/discount-code-10/#post-9553987)
 * Hi edgar!
 * I already organized the code and it works me very well!
 * Thank you very much for your help
 *  Plugin Author [EDGARROJAS](https://wordpress.org/support/users/edgarrojas/)
 * (@edgarrojas)
 * [8 years, 7 months ago](https://wordpress.org/support/topic/discount-code-10/#post-9556001)
 * Ah great =).
 * Let me know if you have any other question.
 * Regards!

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Discount Code’ is closed to new replies.

 * ![](https://ps.w.org/smart-forms/assets/icon-256x256.jpg?rev=1226707)
 * [Smart Forms - when you need more than just a contact form](https://wordpress.org/plugins/smart-forms/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/smart-forms/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/smart-forms/)
 * [Active Topics](https://wordpress.org/support/plugin/smart-forms/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/smart-forms/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/smart-forms/reviews/)

 * 6 replies
 * 2 participants
 * Last reply from: [EDGARROJAS](https://wordpress.org/support/users/edgarrojas/)
 * Last activity: [8 years, 7 months ago](https://wordpress.org/support/topic/discount-code-10/#post-9556001)
 * Status: resolved