bookmark_bordergform_stripe_charge_description

Description

This filter can be used to modify the charge description before it is sent to Stripe.

Usage

The filter which would run for all ‘product and services’ type Stripe feeds can be used like so:

add_filter( 'gform_stripe_charge_description', 'your_function_name', 10, 5 );

Parameters

  • $description string

    The description to be modified.

    $description = 'Entry ID: 123, Products: Product A, Product B, Product C';

  • $strings array

    Contains the Entry ID and Products. This is the array which was imploded to create the description string.

        $strings = array(
            'entry_id' => 'Entry ID: 123',
            'products' => 'Products: Product A, Product B, Product C',
        );
        

  • $entry Entry Object

    The Entry which is currently being processed.

  • $submission_data Submission Data

    Contains the form title, payment amount, setup fee amount, trial amount, line items created using the submitted pricing field values and any discounts from coupons.

  • $feed Feed Object

    The Feed which is currently being processed. Available from v1.7.

Examples

1. Remove the Entry ID

The following example shows how you can remove the entry ID from the description.

add_filter( 'gform_stripe_charge_description', 'remove_entry_id', 10, 2 );
function remove_entry_id( $description, $strings ) {
    unset( $strings['entry_id'] );

    return implode( ', ', $strings );
}

2. Include a field value

The following example shows how you can append the value of a form field to the description.

add_filter( 'gform_stripe_charge_description', 'append_field_value', 10, 3 );
function append_field_value( $description, $strings, $entry ) {

    return $description . ', Name: ' . rgar( $entry, '1.3' ) . ' ' . rgar( $entry, '1.6' );
}

Placement

Your code snippet should be placed in the functions.php file of your active theme.

Source Code

apply_filters( 'gform_stripe_charge_description', implode( ', ', $strings ), $strings, $entry, $submission_data, $feed )

This filter is located in GFStripe::get_payment_description() in class-gf-stripe.php