Displaying Total amount of a donation form With a Short Code

Shortcode - WpScriptly

This concept focuses on developers implementing a system to track the total donation amount collected through a designated form. Users utilize this form to contribute predefined amounts, which are then processed and aggregated. The developer’s task involves creating a backend solution that accurately records each donation transaction, calculates the cumulative sum in real-time, and provides precise reporting of the total donated amount. Key aspects include ensuring secure transaction handling, integrating with payment processing services, and offering analytics to assess the performance of the donation form.

Total paid donation amount

This is a shortcode script that works with Fluent forms – donation script.

I use fluent snippet plugin for all my functions, JS and CSS needs

Place script in the functions.php or use your favorite code snippet plugin

function get_total_amount() {
$entries = $formApi->entries();
//change the 5 to your form ID number
$formApi = fluentFormApi('forms')->entryInstance($formId = 5);
$totalEntries = count($entries);
$totalPaid=0;
for($i=0; $i<$totalEntries; $i++){
if($entries['data'][$i]->payment_status === 'paid'){
$totalPaid+= (($entries['data'][$i]->payment_total)/100);
} }
if (is_int($totalPaid)) {
return '<p class="total">Total Collected Payment:' . '<span> $' . number_format($totalPaid, 2) . '.00' . '</span></p>';
}
// register shortcode
add_shortcode('total_paid', 'get_total_amount');

CSS

Customize the CSS to fit your needs.

.total { 
color:#ccc;
font-weight:bold;
}
.total span {
color:#ff0000;
font-weight:bold;
}

To display the total amount donated via form 5 → change the form id to match your form ID.

Place the shortcode in the shortcode block. You can add a custom style to it as well.

[total_paid]

This script AS IS.

Notes:

Wp Scriptly

This basic script, CSS style, and plugin are designed to function optimally assuming minimal interference from your theme or other plugins. If conflicts occur or further customization is needed, additional adjustments may be necessary. Please note that this script, CSS style, or plugin must be used AS IS.

Wp Scriptly

The WpScriptly Monthly newsletter offers top insights for WordPress pros: new scripts, plugins, resources, tips, tools, updates, and more every month.

Sidebar Subscribe

Comments: