Home / Admin / Dynamically Setting Stripe Payment Description in WPForms
Duplicate Snippet

Embed Snippet on Your Site

Dynamically Setting Stripe Payment Description in WPForms

To dynamically set the Stripe payment description, add the following code snippet to your site.

<10
Code Preview
php
<?php
/**
 * Dynamically set Stripe payment description to include the current page/post title.
 *
 * @link https://wpforms.com/developers/
 *
 * @param array $form_data Form data and settings.
 * @param array $entry Entry data.
 *
 * @return array
 */
function wpf_dev_process_form_data( $form_data, $entry ) {
    // Get the current page/post title
    $page_title = get_the_title();
    // Get the existing payment description and append the page title
    $form_data['payments']['stripe']['payment_description'] = $form_data['payments']['stripe']['payment_description'] . ' - ' . $page_title;
    return $form_data;
}
add_filter( 'wpforms_process_before_form_data', 'wpf_dev_process_form_data', 10, 2 );

Comments

Add a Comment