- Complete mail-in payment gateway for Event Tickets Commerce - Support for check payments with collapsible checkout interface - Admin interface for managing check payments and order status - Professional asset organization with proper WordPress enqueuing - Order management with status tracking (pending, received, bounced) - Template system with responsive design and accessibility features - Integration with Event Tickets Commerce order system - Settings page for configuring payment instructions and addresses
315 lines
No EOL
9.8 KiB
PHP
315 lines
No EOL
9.8 KiB
PHP
<?php
|
|
/**
|
|
* Admin page for managing mail-in payment orders
|
|
*
|
|
* @since 1.0.0
|
|
* @var \WP_Query $pending_orders Query object with pending orders
|
|
*/
|
|
|
|
if ( ! defined( 'ABSPATH' ) ) {
|
|
exit;
|
|
}
|
|
?>
|
|
|
|
<div class="wrap">
|
|
<h1><?php esc_html_e( 'Mail-In Payment Orders', 'event-tickets-mail-in' ); ?></h1>
|
|
|
|
<div class="et-mail-in-admin-header">
|
|
<p><?php esc_html_e( 'Manage orders that are waiting for check payments to arrive.', 'event-tickets-mail-in' ); ?></p>
|
|
</div>
|
|
|
|
<?php if ( $pending_orders->have_posts() ) : ?>
|
|
<div class="et-mail-in-orders-table">
|
|
<table class="wp-list-table widefat fixed striped">
|
|
<thead>
|
|
<tr>
|
|
<th scope="col"><?php esc_html_e( 'Order', 'event-tickets-mail-in' ); ?></th>
|
|
<th scope="col"><?php esc_html_e( 'Customer', 'event-tickets-mail-in' ); ?></th>
|
|
<th scope="col"><?php esc_html_e( 'Event', 'event-tickets-mail-in' ); ?></th>
|
|
<th scope="col"><?php esc_html_e( 'Amount', 'event-tickets-mail-in' ); ?></th>
|
|
<th scope="col"><?php esc_html_e( 'Date', 'event-tickets-mail-in' ); ?></th>
|
|
<th scope="col"><?php esc_html_e( 'Status', 'event-tickets-mail-in' ); ?></th>
|
|
<th scope="col"><?php esc_html_e( 'Actions', 'event-tickets-mail-in' ); ?></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php
|
|
$order_controller = new \ET_Mail_In_Payment\Order();
|
|
while ( $pending_orders->have_posts() ) :
|
|
$pending_orders->the_post();
|
|
$order_id = get_the_ID();
|
|
$order = tribe( 'tickets.commerce.order' )->get_by_id( $order_id );
|
|
$details = $order_controller->get_mail_in_details( $order_id );
|
|
$created_date = get_post_meta( $order_id, '_mail_in_created_date', true );
|
|
$event_id = get_post_meta( $order_id, '_tec_tc_order_event_id', true );
|
|
$event_title = $event_id ? get_the_title( $event_id ) : __( 'N/A', 'event-tickets-mail-in' );
|
|
?>
|
|
<tr>
|
|
<td>
|
|
<strong>
|
|
<a href="<?php echo esc_url( admin_url( 'post.php?post=' . $order_id . '&action=edit' ) ); ?>">
|
|
#<?php echo esc_html( $order->get_order_number() ); ?>
|
|
</a>
|
|
</strong>
|
|
</td>
|
|
<td>
|
|
<?php echo esc_html( $order->get_purchaser_name() ); ?><br>
|
|
<small><?php echo esc_html( $order->get_purchaser_email() ); ?></small>
|
|
</td>
|
|
<td>
|
|
<?php if ( $event_id ) : ?>
|
|
<a href="<?php echo esc_url( admin_url( 'post.php?post=' . $event_id . '&action=edit' ) ); ?>">
|
|
<?php echo esc_html( $event_title ); ?>
|
|
</a>
|
|
<?php else : ?>
|
|
<?php echo esc_html( $event_title ); ?>
|
|
<?php endif; ?>
|
|
</td>
|
|
<td>
|
|
<strong><?php echo esc_html( $order->get_total_value()->get_formatted() ); ?></strong>
|
|
</td>
|
|
<td>
|
|
<?php echo esc_html( date_i18n( get_option( 'date_format' ), strtotime( $created_date ) ) ); ?>
|
|
<br><small><?php echo esc_html( human_time_diff( strtotime( $created_date ), current_time( 'timestamp' ) ) . ' ago' ); ?></small>
|
|
</td>
|
|
<td>
|
|
<span class="et-mail-in-status et-mail-in-status--pending">
|
|
<?php esc_html_e( 'Awaiting Payment', 'event-tickets-mail-in' ); ?>
|
|
</span>
|
|
</td>
|
|
<td>
|
|
<div class="et-mail-in-actions">
|
|
<button type="button" class="button button-secondary et-mail-in-mark-received"
|
|
data-order-id="<?php echo esc_attr( $order_id ); ?>"
|
|
data-order-number="<?php echo esc_attr( $order->get_order_number() ); ?>">
|
|
<?php esc_html_e( 'Mark Received', 'event-tickets-mail-in' ); ?>
|
|
</button>
|
|
<button type="button" class="button button-secondary et-mail-in-mark-bounced"
|
|
data-order-id="<?php echo esc_attr( $order_id ); ?>"
|
|
data-order-number="<?php echo esc_attr( $order->get_order_number() ); ?>">
|
|
<?php esc_html_e( 'Mark Bounced', 'event-tickets-mail-in' ); ?>
|
|
</button>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
<?php endwhile; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<?php
|
|
// Pagination
|
|
$pagination = paginate_links( [
|
|
'total' => $pending_orders->max_num_pages,
|
|
'current' => max( 1, get_query_var( 'paged' ) ),
|
|
'format' => '?paged=%#%',
|
|
'prev_text' => __( '« Previous', 'event-tickets-mail-in' ),
|
|
'next_text' => __( 'Next »', 'event-tickets-mail-in' ),
|
|
] );
|
|
|
|
if ( $pagination ) {
|
|
echo '<div class="tablenav bottom">';
|
|
echo '<div class="tablenav-pages">' . $pagination . '</div>';
|
|
echo '</div>';
|
|
}
|
|
?>
|
|
|
|
<?php else : ?>
|
|
<div class="et-mail-in-no-orders">
|
|
<p><?php esc_html_e( 'No pending mail-in payment orders found.', 'event-tickets-mail-in' ); ?></p>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<?php wp_reset_postdata(); ?>
|
|
</div>
|
|
|
|
<!-- Mark Received Modal -->
|
|
<div id="et-mail-in-received-modal" class="et-mail-in-modal" style="display: none;">
|
|
<div class="et-mail-in-modal-content">
|
|
<span class="et-mail-in-modal-close">×</span>
|
|
<h2><?php esc_html_e( 'Mark Check as Received', 'event-tickets-mail-in' ); ?></h2>
|
|
<form method="post" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>">
|
|
<input type="hidden" name="action" value="mark_check_received">
|
|
<input type="hidden" name="order_id" id="received-order-id">
|
|
<input type="hidden" name="nonce" value="<?php echo esc_attr( wp_create_nonce( 'et_mail_in_admin' ) ); ?>">
|
|
<input type="hidden" name="redirect_url" value="<?php echo esc_url( admin_url( 'edit.php?post_type=tec_tc_order&page=mail-in-payments' ) ); ?>">
|
|
|
|
<p id="received-order-info"></p>
|
|
|
|
<label for="received-notes"><?php esc_html_e( 'Notes (optional):', 'event-tickets-mail-in' ); ?></label>
|
|
<textarea name="notes" id="received-notes" rows="3" style="width: 100%;"></textarea>
|
|
|
|
<div class="et-mail-in-modal-actions">
|
|
<button type="submit" class="button button-primary">
|
|
<?php esc_html_e( 'Mark as Received', 'event-tickets-mail-in' ); ?>
|
|
</button>
|
|
<button type="button" class="button et-mail-in-modal-cancel">
|
|
<?php esc_html_e( 'Cancel', 'event-tickets-mail-in' ); ?>
|
|
</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Mark Bounced Modal -->
|
|
<div id="et-mail-in-bounced-modal" class="et-mail-in-modal" style="display: none;">
|
|
<div class="et-mail-in-modal-content">
|
|
<span class="et-mail-in-modal-close">×</span>
|
|
<h2><?php esc_html_e( 'Mark Check as Bounced', 'event-tickets-mail-in' ); ?></h2>
|
|
<form method="post" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>">
|
|
<input type="hidden" name="action" value="mark_check_bounced">
|
|
<input type="hidden" name="order_id" id="bounced-order-id">
|
|
<input type="hidden" name="nonce" value="<?php echo esc_attr( wp_create_nonce( 'et_mail_in_admin' ) ); ?>">
|
|
<input type="hidden" name="redirect_url" value="<?php echo esc_url( admin_url( 'edit.php?post_type=tec_tc_order&page=mail-in-payments' ) ); ?>">
|
|
|
|
<p id="bounced-order-info"></p>
|
|
|
|
<label for="bounced-reason"><?php esc_html_e( 'Reason for bounce:', 'event-tickets-mail-in' ); ?></label>
|
|
<textarea name="reason" id="bounced-reason" rows="3" style="width: 100%;" required></textarea>
|
|
|
|
<div class="et-mail-in-modal-actions">
|
|
<button type="submit" class="button button-primary">
|
|
<?php esc_html_e( 'Mark as Bounced', 'event-tickets-mail-in' ); ?>
|
|
</button>
|
|
<button type="button" class="button et-mail-in-modal-cancel">
|
|
<?php esc_html_e( 'Cancel', 'event-tickets-mail-in' ); ?>
|
|
</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<style>
|
|
.et-mail-in-admin-header {
|
|
background: #f1f1f1;
|
|
padding: 15px;
|
|
border-radius: 4px;
|
|
margin: 20px 0;
|
|
}
|
|
|
|
.et-mail-in-orders-table {
|
|
margin-top: 20px;
|
|
}
|
|
|
|
.et-mail-in-status {
|
|
padding: 4px 8px;
|
|
border-radius: 3px;
|
|
font-size: 12px;
|
|
font-weight: bold;
|
|
text-transform: uppercase;
|
|
}
|
|
|
|
.et-mail-in-status--pending {
|
|
background: #fff3cd;
|
|
color: #856404;
|
|
border: 1px solid #ffeaa7;
|
|
}
|
|
|
|
.et-mail-in-actions {
|
|
display: flex;
|
|
gap: 5px;
|
|
flex-wrap: wrap;
|
|
}
|
|
|
|
.et-mail-in-actions .button {
|
|
font-size: 11px;
|
|
padding: 2px 8px;
|
|
height: auto;
|
|
}
|
|
|
|
.et-mail-in-no-orders {
|
|
text-align: center;
|
|
padding: 40px;
|
|
background: #f9f9f9;
|
|
border-radius: 4px;
|
|
margin: 20px 0;
|
|
}
|
|
|
|
.et-mail-in-modal {
|
|
position: fixed;
|
|
z-index: 1000;
|
|
left: 0;
|
|
top: 0;
|
|
width: 100%;
|
|
height: 100%;
|
|
background-color: rgba(0,0,0,0.5);
|
|
}
|
|
|
|
.et-mail-in-modal-content {
|
|
background-color: #fefefe;
|
|
margin: 10% auto;
|
|
padding: 20px;
|
|
border-radius: 4px;
|
|
width: 80%;
|
|
max-width: 500px;
|
|
position: relative;
|
|
}
|
|
|
|
.et-mail-in-modal-close {
|
|
position: absolute;
|
|
right: 15px;
|
|
top: 15px;
|
|
font-size: 28px;
|
|
font-weight: bold;
|
|
cursor: pointer;
|
|
}
|
|
|
|
.et-mail-in-modal-close:hover {
|
|
color: #999;
|
|
}
|
|
|
|
.et-mail-in-modal-actions {
|
|
margin-top: 20px;
|
|
display: flex;
|
|
gap: 10px;
|
|
justify-content: flex-end;
|
|
}
|
|
|
|
.et-mail-in-modal h2 {
|
|
margin-top: 0;
|
|
}
|
|
|
|
.et-mail-in-modal label {
|
|
display: block;
|
|
margin: 15px 0 5px 0;
|
|
font-weight: bold;
|
|
}
|
|
</style>
|
|
|
|
<script>
|
|
jQuery(document).ready(function($) {
|
|
// Handle mark received button
|
|
$('.et-mail-in-mark-received').on('click', function() {
|
|
var orderId = $(this).data('order-id');
|
|
var orderNumber = $(this).data('order-number');
|
|
|
|
$('#received-order-id').val(orderId);
|
|
$('#received-order-info').text('Mark check as received for Order #' + orderNumber + '?');
|
|
$('#et-mail-in-received-modal').show();
|
|
});
|
|
|
|
// Handle mark bounced button
|
|
$('.et-mail-in-mark-bounced').on('click', function() {
|
|
var orderId = $(this).data('order-id');
|
|
var orderNumber = $(this).data('order-number');
|
|
|
|
$('#bounced-order-id').val(orderId);
|
|
$('#bounced-order-info').text('Mark check as bounced for Order #' + orderNumber + '?');
|
|
$('#et-mail-in-bounced-modal').show();
|
|
});
|
|
|
|
// Handle modal close
|
|
$('.et-mail-in-modal-close, .et-mail-in-modal-cancel').on('click', function() {
|
|
$('.et-mail-in-modal').hide();
|
|
$('textarea').val('');
|
|
});
|
|
|
|
// Close modal when clicking outside
|
|
$(window).on('click', function(event) {
|
|
if ($(event.target).hasClass('et-mail-in-modal')) {
|
|
$('.et-mail-in-modal').hide();
|
|
$('textarea').val('');
|
|
}
|
|
});
|
|
});
|
|
</script>
|