Created
August 4, 2021 22:45
-
-
Save rafiahmedd/a4006966d303212cd31fcaf51d53022a to your computer and use it in GitHub Desktop.
Show total paid amount anywhere of a site using php api ff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function get_total_amount() { | |
$formApi = fluentFormApi('forms')->entryInstance($formId = 5); | |
$entries = $formApi->entries(); | |
$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 'Total Collected Payment: '.$totalPaid.'.00'; | |
return 'Total Collected Payment: '.$totalPaid; | |
} | |
// register shortcode | |
add_shortcode('total_paid', 'get_total_amount'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment