Title: specific input field similar to coupon in WooCommerce cart
Last modified: August 17, 2023

---

# specific input field similar to coupon in WooCommerce cart

 *  Resolved [s](https://wordpress.org/support/users/sdnazdi/)
 * (@sdnazdi)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/specific-input-field/)
 * Hi,
 * I like to know if there is a possibility to create an input field such that if
   the inserted data is match with some predefined data, it is true, and can be 
   calculated in some way, otherwise not. More precisely, I like to create a calculated
   form for a product and I need one input field similar to “coupon” in WooCommerce,
   such that in the backend I can define a few number of strings composed of numbers,
   letters and symbols separated by “,” or “|” or one per line. Then in the frontend
   if a client enters a string into the field matched with any of the string defined
   behind, I give discount (flat rate or percentage) in calculation, if not, no 
   discount.
 * The following features are more advanced:
    - **Flat Rate or Percentage Discounts** – Configure your coupons to apply either
      a flat rate off the price or a percentage discount off the total price.
    - If these strings are defined by formula or specific regulation it would be
      a plus.
    - **Control Start Date, Expiration Date and Usage** – Set a Start Date and/or
      an Expiration Date and apply Usage limits to control how many times a coupon
      can be used.
    - **Control Stacking** – Control if a coupon can be applied when another coupon
      has already been applied. Prevent double dipping!
 * If you need more explanations I can give it more.
 * Thanks.
    -  This topic was modified 2 years, 9 months ago by [s](https://wordpress.org/support/users/sdnazdi/).
    -  This topic was modified 2 years, 9 months ago by [s](https://wordpress.org/support/users/sdnazdi/).
    -  This topic was modified 2 years, 9 months ago by [s](https://wordpress.org/support/users/sdnazdi/).
    -  This topic was modified 2 years, 9 months ago by [s](https://wordpress.org/support/users/sdnazdi/).
    -  This topic was modified 2 years, 9 months ago by [s](https://wordpress.org/support/users/sdnazdi/).
    -  This topic was modified 2 years, 9 months ago by [s](https://wordpress.org/support/users/sdnazdi/).
    -  This topic was modified 2 years, 9 months ago by [s](https://wordpress.org/support/users/sdnazdi/).
    -  This topic was modified 2 years, 9 months ago by [s](https://wordpress.org/support/users/sdnazdi/).
    -  This topic was modified 2 years, 9 months ago by [s](https://wordpress.org/support/users/sdnazdi/).
    -  This topic was modified 2 years, 9 months ago by [s](https://wordpress.org/support/users/sdnazdi/).

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

 *  Plugin Support [Patrick – WPMU DEV Support](https://wordpress.org/support/users/wpmudevsupport12/)
 * (@wpmudevsupport12)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/specific-input-field/#post-16984680)
 * Hi [@sdnazdi](https://wordpress.org/support/users/sdnazdi/)
 * I hope you are doing well,
 * I am afraid it is not possible, you can compare strings and create conditionals
   based on the input: [https://wpmudev.com/docs/wpmu-dev-plugins/forminator/#Forminator-Conditional-Logic](https://wpmudev.com/docs/wpmu-dev-plugins/forminator/#Forminator-Conditional-Logic)
 * Then create an extra calculation field for example:
 * – Discount applied {calculation-1} = Formula 10/100, set visibility based on 
   the input, and Null in case it doesn’t exist to prevent the 0 in calculation 
   2.
 * – Final Price {calculation-2} = valor_product – valor_product * {calculation-
   1}
 * But it is a simple solution where we can’t control if the coupon is used or not
   in the past or track it, for a more complex control a plugin such as Woo is more
   appropriate.
 * Best Regards
    Patrick Freitas
 *  Thread Starter [s](https://wordpress.org/support/users/sdnazdi/)
 * (@sdnazdi)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/specific-input-field/#post-16985518)
 * thanks [@wpmudevsupport12](https://wordpress.org/support/users/wpmudevsupport12/),
 * Please let me know what type of field should I define to verify if the coupon
   is matched or not? Since if I create a checkbox, radio or select field, and ask
   him/her to select a coupon from the list, of course the client can choose any
   of them to see the calculation and see the discount. You know what I mean? So
   I need more secure field.
 * regards
    -  This reply was modified 2 years, 9 months ago by [s](https://wordpress.org/support/users/sdnazdi/).
    -  This reply was modified 2 years, 9 months ago by [s](https://wordpress.org/support/users/sdnazdi/).
    -  This reply was modified 2 years, 9 months ago by [s](https://wordpress.org/support/users/sdnazdi/).
 *  Plugin Support [Laura – WPMU DEV Support](https://wordpress.org/support/users/wpmudev-support8/)
 * (@wpmudev-support8)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/specific-input-field/#post-16989001)
 * Hi [@sdnazdi](https://wordpress.org/support/users/sdnazdi/)
 * There is no option to support such verification but the “visibility condition”
   solution suggested by my colleague doesn’t really requite it.
 * What you could do would be to add a single “input” type field where user enters
   coupon code (not selects it but just enters – types it in manually or copy-paste)
   and then this would be used to use calculations.
 * I’ve created example form for you so you could get a better idea how it works.
   You will find the form here
 * [https://pastebin.com/JEUdU5xH](https://pastebin.com/JEUdU5xH)
 * so you can import it to your site and test.
 * In general:
 * – there’s “input” field which is a text field where user can “freehand” enter
   something
    – then there is a hidden “base price” calculation field where you 
   set your base price;
 * – then you have two calculation fields;
 * first one is for “fixed” discount so in my example it’s just a value of 150 (
   so base price would be lowered by 150 if this is applied)
 * second one is for “percentage” discount so in my example it’s 10%, therefore 
   it calculates 10% of base prices
 * – these two calculation fields have visibility conditions set based on the input
   field; conditions are based on “is” rule and the value defined there is your 
   coupon code; since you can add multiple rules, you can define multiple codes 
   this way and this determines which of these fields (discounts) would be applied;
   user does NOT see these coupons on front-end and in page source; so they can’t
   know them
 * – finally, there’s one more calculation fields which simply subtracts sum of 
   both discounts (due to visibility rules that sum will always be equal to only
   one of the discounts based on the coupon because the other one will be zero and“
   zero+something” is always that “something”) from the base price.
 * In this example I set base price of 500, fixed discount to be 150 and percentage
   discount to be 10%. If you put “abc” text (coupon code) into input field, you’ll
   see that discount is 150 and final price to pay is 350; if you put “def” text(
   coupon code) into input field, you’ll see that discount is 50 (10% of 500 = 50)
   nd price to pay is 450.
 * Best regards,
    Adam
 *  Thread Starter [s](https://wordpress.org/support/users/sdnazdi/)
 * (@sdnazdi)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/specific-input-field/#post-16989438)
 * Hi [@wpmudev-support8](https://wordpress.org/support/users/wpmudev-support8/),
   thanks for your reply. I can add as many as rules “any” for different coupons
   in visibility condition.
 *  Plugin Support [Laura – WPMU DEV Support](https://wordpress.org/support/users/wpmudev-support8/)
 * (@wpmudev-support8)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/specific-input-field/#post-16989451)
 * Hi [@sdnazdi](https://wordpress.org/support/users/sdnazdi/)
 * > I can add as many as rules “any” for different coupons in visibility condition.
 * Yes, you definitely can. For as long as you keep the “Show if ANY” rule set instead
   of “Show if ALL” – it will work. This way you can define multiple coupon codes
   and users will not know them unless you actually tell them the codes.
 * Best regards,
    Adam

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

The topic ‘specific input field similar to coupon in WooCommerce cart’ is closed
to new replies.

 * ![](https://ps.w.org/forminator/assets/icon-256x256.gif?rev=3443182)
 * [Forminator Forms – Contact Form, Payment Form & Custom Form Builder](https://wordpress.org/plugins/forminator/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/forminator/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/forminator/)
 * [Active Topics](https://wordpress.org/support/plugin/forminator/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/forminator/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/forminator/reviews/)

 * 5 replies
 * 3 participants
 * Last reply from: [Laura – WPMU DEV Support](https://wordpress.org/support/users/wpmudev-support8/)
 * Last activity: [2 years, 9 months ago](https://wordpress.org/support/topic/specific-input-field/#post-16989451)
 * Status: resolved