event-tickets-mail-in-payment/templates/admin/order-meta-box.php
Ruben Ramirez 8fd8d9708c Initial commit: Complete Event Tickets Mail-In Payment Gateway
- 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
2025-06-30 21:56:49 -04:00

218 lines
No EOL
7.2 KiB
PHP

<?php
/**
* Order meta box template for mail-in payments
*
* @since 1.0.0
* @var \WP_Post $post Order post object
* @var array $details Mail-in payment details
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
?>
<div class="et-mail-in-order-details">
<table class="form-table">
<tbody>
<tr>
<th scope="row"><?php esc_html_e( 'Payment Method', 'event-tickets-mail-in' ); ?></th>
<td><?php esc_html_e( 'Mail-In Payment (Check)', 'event-tickets-mail-in' ); ?></td>
</tr>
<tr>
<th scope="row"><?php esc_html_e( 'Check Status', 'event-tickets-mail-in' ); ?></th>
<td>
<?php if ( $details['check_received'] ) : ?>
<span class="et-mail-in-status et-mail-in-status--received">
<?php esc_html_e( 'Received', 'event-tickets-mail-in' ); ?>
</span>
<?php if ( $details['check_received_date'] ) : ?>
<br><small><?php echo esc_html( sprintf( __( 'Received on: %s', 'event-tickets-mail-in' ), date_i18n( get_option( 'date_format' ), strtotime( $details['check_received_date'] ) ) ) ); ?></small>
<?php endif; ?>
<?php elseif ( $details['check_bounced'] ) : ?>
<span class="et-mail-in-status et-mail-in-status--bounced">
<?php esc_html_e( 'Bounced', 'event-tickets-mail-in' ); ?>
</span>
<?php if ( $details['bounce_date'] ) : ?>
<br><small><?php echo esc_html( sprintf( __( 'Bounced on: %s', 'event-tickets-mail-in' ), date_i18n( get_option( 'date_format' ), strtotime( $details['bounce_date'] ) ) ) ); ?></small>
<?php endif; ?>
<?php else : ?>
<span class="et-mail-in-status et-mail-in-status--pending">
<?php esc_html_e( 'Awaiting Payment', 'event-tickets-mail-in' ); ?>
</span>
<?php endif; ?>
</td>
</tr>
<?php if ( $details['created_date'] ) : ?>
<tr>
<th scope="row"><?php esc_html_e( 'Order Created', 'event-tickets-mail-in' ); ?></th>
<td>
<?php echo esc_html( date_i18n( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), strtotime( $details['created_date'] ) ) ); ?>
<br><small><?php echo esc_html( human_time_diff( strtotime( $details['created_date'] ), current_time( 'timestamp' ) ) . ' ago' ); ?></small>
</td>
</tr>
<?php endif; ?>
<?php if ( $details['payable_to'] ) : ?>
<tr>
<th scope="row"><?php esc_html_e( 'Check Payable To', 'event-tickets-mail-in' ); ?></th>
<td><strong><?php echo esc_html( $details['payable_to'] ); ?></strong></td>
</tr>
<?php endif; ?>
<?php if ( $details['mailing_address'] ) : ?>
<tr>
<th scope="row"><?php esc_html_e( 'Mailing Address', 'event-tickets-mail-in' ); ?></th>
<td>
<div class="et-mail-in-address">
<?php echo wp_kses_post( nl2br( $details['mailing_address'] ) ); ?>
</div>
</td>
</tr>
<?php endif; ?>
<?php if ( $details['check_notes'] ) : ?>
<tr>
<th scope="row"><?php esc_html_e( 'Payment Notes', 'event-tickets-mail-in' ); ?></th>
<td><?php echo wp_kses_post( nl2br( $details['check_notes'] ) ); ?></td>
</tr>
<?php endif; ?>
<?php if ( $details['bounce_reason'] ) : ?>
<tr>
<th scope="row"><?php esc_html_e( 'Bounce Reason', 'event-tickets-mail-in' ); ?></th>
<td><?php echo wp_kses_post( nl2br( $details['bounce_reason'] ) ); ?></td>
</tr>
<?php endif; ?>
</tbody>
</table>
<?php if ( ! $details['check_received'] && ! $details['check_bounced'] ) : ?>
<div class="et-mail-in-actions">
<h4><?php esc_html_e( 'Payment Actions', 'event-tickets-mail-in' ); ?></h4>
<p><?php esc_html_e( 'Use these actions to update the payment status when you receive or process the check.', 'event-tickets-mail-in' ); ?></p>
<div class="et-mail-in-action-buttons">
<button type="button" class="button button-primary et-mail-in-mark-received-single"
data-order-id="<?php echo esc_attr( $post->ID ); ?>">
<?php esc_html_e( 'Mark Check as Received', 'event-tickets-mail-in' ); ?>
</button>
<button type="button" class="button button-secondary et-mail-in-mark-bounced-single"
data-order-id="<?php echo esc_attr( $post->ID ); ?>">
<?php esc_html_e( 'Mark Check as Bounced', 'event-tickets-mail-in' ); ?>
</button>
</div>
</div>
<?php endif; ?>
</div>
<style>
.et-mail-in-order-details .form-table th {
width: 150px;
font-weight: 600;
}
.et-mail-in-status {
display: inline-block;
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-status--received {
background: #d4edda;
color: #155724;
border: 1px solid #c3e6cb;
}
.et-mail-in-status--bounced {
background: #f8d7da;
color: #721c24;
border: 1px solid #f5c6cb;
}
.et-mail-in-address {
background: #f5f5f5;
padding: 10px;
border-radius: 4px;
border-left: 4px solid #0073aa;
line-height: 1.6;
}
.et-mail-in-actions {
margin-top: 20px;
padding-top: 20px;
border-top: 1px solid #ddd;
}
.et-mail-in-actions h4 {
margin: 0 0 10px 0;
}
.et-mail-in-action-buttons {
margin-top: 15px;
}
.et-mail-in-action-buttons .button {
margin-right: 10px;
}
</style>
<script>
jQuery(document).ready(function($) {
$('.et-mail-in-mark-received-single').on('click', function() {
var orderId = $(this).data('order-id');
var notes = prompt('<?php echo esc_js( __( 'Optional notes about the received check:', 'event-tickets-mail-in' ) ); ?>');
if (notes !== null) { // User didn't cancel
var form = $('<form>', {
'method': 'POST',
'action': '<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>'
});
form.append($('<input>', {'type': 'hidden', 'name': 'action', 'value': 'mark_check_received'}));
form.append($('<input>', {'type': 'hidden', 'name': 'order_id', 'value': orderId}));
form.append($('<input>', {'type': 'hidden', 'name': 'notes', 'value': notes}));
form.append($('<input>', {'type': 'hidden', 'name': 'nonce', 'value': '<?php echo esc_attr( wp_create_nonce( 'et_mail_in_admin' ) ); ?>'}));
form.append($('<input>', {'type': 'hidden', 'name': 'redirect_url', 'value': window.location.href}));
$('body').append(form);
form.submit();
}
});
$('.et-mail-in-mark-bounced-single').on('click', function() {
var orderId = $(this).data('order-id');
var reason = prompt('<?php echo esc_js( __( 'Reason for check bounce (required):', 'event-tickets-mail-in' ) ); ?>');
if (reason && reason.trim() !== '') {
var form = $('<form>', {
'method': 'POST',
'action': '<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>'
});
form.append($('<input>', {'type': 'hidden', 'name': 'action', 'value': 'mark_check_bounced'}));
form.append($('<input>', {'type': 'hidden', 'name': 'order_id', 'value': orderId}));
form.append($('<input>', {'type': 'hidden', 'name': 'reason', 'value': reason}));
form.append($('<input>', {'type': 'hidden', 'name': 'nonce', 'value': '<?php echo esc_attr( wp_create_nonce( 'et_mail_in_admin' ) ); ?>'}));
form.append($('<input>', {'type': 'hidden', 'name': 'redirect_url', 'value': window.location.href}));
$('body').append(form);
form.submit();
} else if (reason !== null) {
alert('<?php echo esc_js( __( 'Please provide a reason for the bounce.', 'event-tickets-mail-in' ) ); ?>');
}
});
});
</script>