Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save rafiahmedd/a4006966d303212cd31fcaf51d53022a to your computer and use it in GitHub Desktop.
Save rafiahmedd/a4006966d303212cd31fcaf51d53022a to your computer and use it in GitHub Desktop.
Show total paid amount anywhere of a site using php api ff
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