Conditionally Display a Field Based on a Recurring Date

Automatic Conditional Logic with wildcard dates.

This article requires the Gravity Forms Conditional Logic Dates perk.

Buy Gravity Perks to get this perk plus 47 other premium Gravity Forms plugins!

View Plugin Buy Gravity Perks

Overview

There are a number of situations where your form should only show a field on a specific set of days. For example, you might offer off-season discounts for products in your shop or want to enforce late fees for payments after a certain day of the month. In this tutorial we’re going to cover how to tackle these scenarios using GF Conditional Logic Dates.

  1. Overview
  2. Off Season Pricing
  3. Late Fees
  4. Taking It Further

Off Season Pricing

Tourism in most places typically has a busy and slow season which coincides with weather patterns or other factors. Pricing for goods and services in these locations usually fluctuates with the season, and remembering to update your form seasonally is asking for trouble. Instead, automate the process by showing a different Product field using Conditional Logic.

Start by adding a couple of Product fields to your form with the different prices for each season. I like to add a description to the discounted field so customers know they’re getting a deal.

Frisbees

Then, add a Date field to the form. The date input here will be used for Conditional Logic in the next step. If you want to automatically set the date to the current date, insert the {date_mdy} merge tag into the Default Value field.

Frisbees

For each of the Product fields, add Conditional Logic to show the field during the different seasons using wildcards. In my example, windy season is November through January, so the conditional logic is set to show this field if the Date field matches any day in any of those three months.

Windy Season Product

Your form will automatically show/hide the appropriate Product based on the date in the Date field.

Seasonal Front End Animated

This same process can be used for any recurring date-specific discount you want to apply. Have the same Black Friday sale every year and don’t want to have to create a unique form for it? This spell is set-and-forget.

Simplify your discounts by using GF eCommerce Fields Discount fields.

Late Fees

If you have an online payment form that must be paid by a certain date, adding late fees for any late payments is a breeze. Start by adding a Date field to your form and set its Default Value to the {date_mdy} merge tag. Then, add a Product field with quantity disabled. Set your fixed late fee as the Product’s price and set the conditional logic using wildcards.

Late Fees

Notice the use of greater than in the conditional logic here. This late fee will apply to any day after the 5th of each month.

Taking It Further

Conditional Logic Dates adds conditional logic to any place that Gravity Forms supports it, which includes GF Conditional Pricing. Wildcard dates work there, too! Set up complex pricing rules that automatically adjust based on the current date or user-submitted date. The possibilities are endless!

Comments

  1. rosswog
    rosswog September 25, 2024 at 12:52 pm

    Is it possible to use this to set a date for a certain day in any month like, “Display if Date Select is the First Tuesday of Each Month”?

    Reply
    1. Scott Ryer
      Scott Ryer Staff September 26, 2024 at 1:28 pm

      We don’t have a ready solution for this. I’ll pass this along to our product manager as a feature request.

    2. David Smith
      David Smith Staff October 4, 2024 at 5:30 pm

      Based on our email conversation, you figured out such a clever solution, rosswog!

      For other users interested, to show a field only on the first Tuesday of the month, you can leverage Gravity Forms’ conditional logic. Rosswog set up the form to check two conditions: if the selected day is {tuesday} and the date is less than the 8th (*/8/*). You can check for second and third Tuesdays by extending the date.

      So clever!

Leave a Reply

Your email address will not be published. Required fields are marked *

  • Trouble installing this snippet? See our troubleshooting tips.
  • Need to include code? Create a gist and link to it in your comment.
  • Reporting a bug? Provide a URL where this issue can be recreated.

By commenting, I understand that I may receive emails related to Gravity Wiz and can unsubscribe at any time.

Grab a bundle of free Gravity Forms plugins

Enter your email and receive our most popular free plugins and snippets, plus access to hundreds of others.

This field is for validation purposes and should be left unchanged.