Skip to content

Instantly share code, notes, and snippets.

@patrickfreitasdev
Last active November 6, 2022 13:41
Show Gist options
  • Save patrickfreitasdev/df8e7f677074b540c69aa0c351c547f0 to your computer and use it in GitHub Desktop.
Save patrickfreitasdev/df8e7f677074b540c69aa0c351c547f0 to your computer and use it in GitHub Desktop.
<?php
/**
* Show Forminator payment data on the front end using Forminator API
* Make sure to create an hidden filed to collect the user ID
*
*/
//Using this to protect the plugin
defined('ABSPATH') or die('What are you looking for?');
function wpmu_order_status_876(){
ob_start();
$form_id = 194;
$entries = Forminator_API::get_entries( $form_id );
$currentUserId = (int)get_current_user_id();
$orderStatus = [];
$ordersId = [];
// Collect the submission from the logged-in user based on the hidden-field user ID, update the hidden-1 if necessary
foreach($entries as $entrie){
$hiddenFiled = (int)$entrie->meta_data['hidden-1']['value'];
if($currentUserId === $hiddenFiled ){
$ordersId[] =(int)$entrie->entry_id;
}
}
// Format the orders payment information
foreach($ordersId as $entry_id){
$entry = Forminator_API::get_entry( $form_id, $entry_id );
$orderStatus[] = [
'status' => $entry->meta_data['stripe-1']['value']['status'],
'amount' => $entry->meta_data['stripe-1']['value']['amount'],
'transaction_id' => $entry->meta_data['stripe-1']['value']['transaction_id'],
];
}
?>
<!-- Font End Data -->
<div class="payment-info">
<?php foreach($orderStatus as $oder):?>
<table>
<tbody>
<tr>
<td>Status</td>
<td><?= $oder['status']; ?></td>
</tr>
<tr>
<td>Ammount</td>
<td><?= $oder['amount']; ?></td>
</tr>
<tr>
<td>Payment ID:</td>
<td><?= $oder['transaction_id']; ?>/td>
</tr>
</tbody>
</table>
<?php endforeach; ?>
<br>
</div>
<?php
return ob_get_clean();
}add_shortcode('forminator-order-status','wpmu_order_status_876');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment