Setting Up Conditional Payments in Gravity Forms

Setting Up Conditional Payments in Gravity Forms

Sometimes, you may want to allow a user to either pay with one payment gateway or another. In this article, we will show you how to send a payment to either PayPal or Stripe based on the user』s options using conditional logic. You can apply the same setup to any other combination of different payment options within a form (e.g. PayPal + Authorize.net or letting the user choose between different payment feeds of the same add-on).

Note: This article assumes that you already know how to create a payment form, as well as you have installed the add-ons for all payment gateways you need.

First either create or access your payment form by clicking on Forms on the left side navigation menu, and then clicking on the form that you want to enable multiple payment gateways on.

If you want a user to be able to select the payment gateway, add a Radio Button field type to your form, with each option being the different payment options. In this example, we will be using PayPal and Stripe, so both of these options will be labeled accordingly as PayPal and Credit Card within a radio button field.

Next, we need to display the credit card form conditionally based on the payment selection. As PayPal Standard is handled off-site, there』s no need for the user to fill out the credit card form. To do so, click on the Credit Card field, click on the Conditional Logic section, then check the toggle on to Enable Conditional Logic. Once the conditional logic option appears, simply configure this field to only show if the Credit Card radio button is selected.

That』s all we need from the form itself. Now, we』re on to configuring conditional logic within our feeds for each payment gateway. On the top of the page, hover over Form Settings and click on the payment gateway you want to configure. As you are likely already using this payment gateway, you likely already have a feed so we won』t go through the process of creating feeds, but you can find that information if you need it within the documentation for the add-on you are using. Simply access the feed you want to use. In this example, we will be configuring PayPal』s feed, but the steps will be the same for any other payment gateway add-on.

Within the feed, there is an option labeled Conditional Logic. Simply check the checkbox beside it to enable conditional logic.

To configure your condition, simply set it to occur (or not occur) based on your desired selection. In this example, we are letting the user choose between PayPal and credit card options, and are configuring the PayPal feed, so we simply set the condition to occur only if the PayPal radio button is selected.

From here, continue to set up any other feeds that will occur based on the user』s selection. In this example, we would set the same conditional logic for the Stripe feed to only process if the Credit Card radio button is selected.

Congratulations. You have now successfully set up multiple payment gateways using conditional logic in Gravity Forms.

Select Custom Field

Select Custom Field

IntroductionExampleUses

Introduction
The select_custom type field, part of the Settings API, allows the user to select a choice in a drop down or enter their own custom value in a text input.
Example
This field will output a select field containing the specified choices. In this example get_field_map_choices() is used to return an array of choices containing the date type fields from the current form.
It will also have an extra choice appended to the end of the list which when selected will hide the select field and display a text field allowing the user to enter a custom choice.
The content from the after_input property will appear after the text input, it will be hidden when the select is displayed.
array(
'title' => esc_html__( 'This is the title for Section 1', 'sometextdomain' ),
'fields' => array(
array(
'name' => 'cardDueDate',
'type' => 'select_custom',
'label' => esc_html__( 'Due Date', 'sometextdomain' ),
'after_input' => ' ' . esc_html__( 'days after today', 'sometextdomain' ),
'choices' => $this->get_field_map_choices( rgget( 'id' ), 'date' ),
'required' => true,
),
),
),

The code above will render the select field similar to the following:

When the 「Add Custom Due Date」 choice is selected the select will be hidden and a text input like this would be displayed:

Uses

settings_select_custom()
settings_select()
settings_text()

rgar()

rgar()

DescriptionUsageParametersReturnsExamples1. Key exists2. Key does not exist3. Key does not exist but default value provided4. Used with IF statement5. Used with Ternary ShorthandSource Code

Description

Get a specific property of an array without needing to check if that property exists.

Provide a default value if you want to return a specific value if the property is not set.

Usage

rgar( $array, $prop );

rgar( $array, $prop, $default_value );

Parameters

$array arrayArray from which the property』s value should be retrieved.   $prop stringName of the property to be retrieved. $default_value stringValue that should be returned if the property is not set or empty. Defaults to null. This parameter is OPTIONAL.

Returns

null|string|mixed The value

Examples

1. Key exists

This example will return the value for the key 「dog」 – Roddenberry.

$pets = array(
'dog' => 'Roddenberry',
'cat' => 'Tucker'
);
rgar( $pets, 'dog' );

2. Key does not exist

This example returns the value for the key 「ferret」. Since this key does not exist and no default value was provided to the function, null is returned.

$pets = array(
'dog' => 'Roddenberry',
'cat' => 'Tucker'
);
rgar( $pets, 'ferret' );

3. Key does not exist but default value provided

This example returns the value for the key 「ferret」. Since this key does not exist the default value passed to the function is returned – Malcolm.

$pets = array(
'dog' => 'Roddenberry',
'cat' => 'Tucker'
);
rgar( $pets, 'ferret', 'Malcolm' );

4. Used with IF statement

This examples checks the Form Object to see if the honey pot is enabled.

// Honey pot.
$honey_pot_checked = '';
if ( rgar( $form, 'enableHoneypot' ) ) {
$honey_pot_checked = 'checked="checked"';
}

5. Used with Ternary Shorthand

This example checks the Confirmation Object to see if its type is set, if so, the confirmation type is set to its value, otherwise the type is set to 「message」.

$confirmation_type = rgar( $confirmation, 'type' ) ? rgar( $confirmation, 'type' ) : 'message';

Source Code

This function is located in gravityforms.php

Setting Up the PayPal Payments Pro Add-On

Setting Up the PayPal Payments Pro Add-On

Pre-RequisitesSetupAdding a Credit Card Field

Pre-Requisites

Download and install the add-on
PayPal Payments Pro account

Setup
Before you can begin using the PayPal Payments Pro Add-On, you will first need to properly configure it. This process involves obtaining API keys and inserting them into the add-ons settings page. We』ll show you how below.

Log into your WordPress admin dashboard.
On the left side navigation menu, hover over Forms and click on Settings.
From this page, click the PayPal Payments Pro tab.
The API setting allows you to switch between sandbox (testing) and live transactions. We always recommend setting this to Sandbox to avoid accidental charges and to assist with testing until you are ready to process live transactions.
Username and Password: These will be the Payflow credentials that you have set when creating your PayPal Payments Pro account and are used to log into the PayPal Manager. If you are unsure of these, you can always access the PayPal Manager site to either recover your existing credentials or make a new account. Enter your username and password into the designated fields.
Some companies may have a specific merchant login that they will need to use, which differs from the username. If you have a separate merchant login, enter it within the field labeled Vendor. If you don』t have one, or don』t know what this is, you can leave this field empty as it is likely not needed.
Partner: If you created your PayPal Payments Pro account through a reseller, then you will need to enter the appropriate partner here. If you signed up directly, you』ll simply leave this field as PayPal.
Click Update Settings. If you』ve entered your account information correctly, you will be notified by green check marks beside each box. If you do not see green check marks, please double check this information and try again.

Once you have entered your API information, you』re ready to begin creating a feed for the PayPal Payments Pro Add-On.
Adding a Credit Card Field

Note: When using Page fields to create a multi-page form, the Credit Card field must be located on the last page of your form.

Once you have set up the PayPal Pro credentials, you』ll need to add a Credit Card field to be able to accept credit cards within your form. To do so, access the Form Editor and add a Credit Card field.
If you need more information on Credit Card fields, take a look at the credit card field documentation.

{score} Merge Tag

{score} Merge Tag

SummaryUsageModifiersNotes

Summary

Displays the score for a specific survey question. Scoring must be enabled on the survey field for it to be tallied.

Usage

{score:id=x}

Modifiers

:id

The ID of the specific survey question

Notes

Quiz and Survey related merge tags can only be used in confirmations and notifications.For more information, Refer to our Survey Add-On documentation.

SendGrid Change Log

SendGrid Change Log

1.5 | 2021-04-291.4 | 2020-09-241.3 | 2020-03-241.2 | 2019-02-141.1 | 2018-11-151.0 | 2018-11-08

1.5 | 2021-04-29

Added a menu icon for Gravity Forms 2.5.
Updated the icon on the notifications screen of form settings to match the menu icon in Gravity Forms 2.5.

1.4 | 2020-09-24

Added support for Gravity Forms 2.5.
Added support for sending result notes.
Added gform_sendgrid_send_email_failed hook to allow developers to take additional actions when email sending fails.

1.3 | 2020-03-24

Added translations for Hebrew, Hindi, Japanese, and Turkish.
Improved logging to include notification id, notification name, and entry id in the sending process.

1.2 | 2019-02-14

Fixed merge tags not being replaced in the From Name.
Fix an issue where only the first recipient in the TO and BCC would receive the email.

1.1 | 2018-11-15

Fix issue with merge tags not being replaced in BCC and Reply To headers.

1.0 | 2018-11-08

It's all new!

rgpost()

rgpost()

DescriptionUsageParametersExamples1. Single Input Field Type2. Multi-input Field TypeSource Code

Description
Access an input value from a POST request.
Usage
1rgpost( $name, $do_stripslashes );

Parameters

$name string
The input name that you want to access in the POST request.

$do_stripslashes boolean
Indicates if the stripslashes_deep() function should be applied to the retrieved value before it is returned. Defaults to true

Examples
1. Single Input Field Type
This example shows how you can access the value from a single input field.
1$value = rgpost( 'input_1', true );
2. Multi-input Field Type
This example shows how you can access the value from a specific input in a multi-input type field. In this example we are accessing the value from input 3 of field 1.
1$value = rgpost( 'input_1_3' );
Source Code
This function is located in gravityforms.php

Select Field

Select Field

IntroductionExampleUses

Introduction
The select type field, part of the Settings API, allows the user to select a choice from a drop down.
Example
The following example shows a section with two select type fields. The first is a simple select with two choices. The second select field has two choices with the first choice having sub-choices (an option group).
array(
'title' => esc_html__( 'This is the title for Section 1', 'sometextdomain' ),
'description' => esc_html__( 'This is a description of the purpose of Section 1', 'sometextdomain' ),
'fields' => array(
array(
'type' => 'select',
'name' => 'myselect',
'label' => esc_html__( 'This is a select', 'sometextdomain' ),
'choices' => array(
array(
'label' => esc_html__( 'my first choice', 'sometextdomain' ),
'value' => '1'
),
array(
'label' => esc_html__( 'my second choice', 'sometextdomain' ),
'value' => '2'
)
)
),
array(
'type' => 'select',
'name' => 'myselect2',
'label' => esc_html__( 'This is my select', 'sometextdomain' ),
'default_value' => 'first - 3',
'choices' => array(
array(
'label' => esc_html__( 'This is my first choice', 'sometextdomain' ),
'value' => 'first',
'choices' => array(
array(
'label' => esc_html__( 'first - 1', 'sometextdomain' ),
'value' => 'f1'
),
array(
'label' => esc_html__( 'first - 2', 'sometextdomain' ),
'value' => 'f2',
),
array(
'label' => esc_html__( 'first - 3', 'sometextdomain' ),
),
),
),
array(
'label' => esc_html__( 'This is my second choice', 'sometextdomain' ),
'value' => 'second',
),
),
)
),
),

The code above will render the select fields similar to the following:

Uses

settings_select()
get_select_options()
get_select_option()

rgars()

rgars()

DescriptionUsageParametersExamplesSource Code

Description
Finds a value within a multi level array. Forward slashes ( / ) are used to descend down the structure of the array.
Usage
1rgars( $array, $name );
Parameters

$array array
The array that you want to obtain a value from.

$name string
The array keys, separated by a forward slash, to be located.

Examples
12345678910// Defines the multilevel array, and transcends it to get the value.$array = array(   'firstlevel' => array(      'secondlevel' => array(         'thirdlevel' => 'Desired Value'       )   ))$name = 'firstlevel/secondlevel/thirdlevel';rgars( $array, $name );
Source Code
This function is located in gravityforms.php

Setting Up the Pipe Add-On

Setting Up the Pipe Add-On

Pre-RequisitesSetupAdding Pipe to Your Form

To use the Gravity Forms Pipe Add-On, you』ll first need to configure it. In this article, we』ll show you how to fully configure and use the Pipe Add-On for embedding a video recorder into your form.

Pre-Requisites

Download and install the add-onA Pipe account

Setup

Log into your WordPress admin dashboard.On the left side navigation menu, hover over Forms and click on Settings.From this page, click the Pipe tab.Enter your Account Hash and API Key. This can be found by logging into your Pipe account and clicking on Account at the top of the page.Click Update Settings. If you』ve entered your account information correctly, you will be notified by green check marks beside each box. If you do not see green check marks, please double check this information and try again.

Once you have entered your API key, you』re ready to add Pipe to your form.

Adding Pipe to Your Form

To add Pipe video recording to your form, you』ll need to add the Pipe field by using the form editor. See our User Guide for the Pipe Recording Field for more information.