Skip to content

Instantly share code, notes, and snippets.

@Garconis
Last active March 20, 2018 13:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Garconis/9e603f17c3077af1408b6036cf55c101 to your computer and use it in GitHub Desktop.
Save Garconis/9e603f17c3077af1408b6036cf55c101 to your computer and use it in GitHub Desktop.
WooCommerce | Show only open tickets in WooCommerce Dashboard to user for Awesome tickets plugin
<?php
add_action( 'woocommerce_account_dashboard', 'my_dashboard_tickets' );
function my_dashboard_tickets() {
$user_id = get_current_user_id();
$ticket_options = array(
'post_type' => 'ticket',
'order' => 'DESC',
'orderby' => 'date',
'posts_per_page' => -1,
'meta_key' => '_wpas_status',
'meta_value' => 'open',
'author' => $user_id,
);
$loop = new WP_Query( $ticket_options );
if ( $loop->have_posts() ) {
echo '<div class="dashboard-tickets-wrapper">
<h3>Open Tickets</h3>
<table class="shop_table shop_table_responsive">
<tr>
<th>Ticket</th>
<th>Submission Date</th>
<th>Status</th>
<th>Type</th>
</tr>';
while ( $loop->have_posts() ) : $loop->the_post();
// the ticket status is just Open or Close, so we want the actual ticket state.
$status = wpas_get_ticket_status( $ticket_id );
// list Product Type taxonomy term
$product_type = get_the_term_list( $post->ID, 'product', '', ', ' );
// strip the anchor links around each type
$product_type = strip_tags( $product_type );
// Ticket State
$ticket_id = get_the_ID();
$ticket = get_post( $ticket_id );
$ticket_status = $ticket->post_status;
$ticket_custom_status = wpas_get_post_status();
$ticket_custom_status_state = $ticket_custom_status[ $ticket_status ];
$ticket_custom_status_state_class = 'ticket-status-label-badge ticket-status-' . sanitize_title($ticket_custom_status_state);
echo' <tr>
<td class="ticket-title" data-title="Project">' . get_the_title() . '<br> <a href="' . get_permalink() . '">View Details &raquo;</a></td>
<td class="ticket-date" data-title="Submission Date">' . get_the_date() . '</td>
<td class="ticket-status" data-title="Status"><span class="' . $ticket_custom_status_state_class . '">' . $ticket_custom_status_state . '</span></td>
<td class="ticket-type" data-title="Type">' . $product_type . '</td>
</tr>';
endwhile;
echo' </table>
</div>';
} // end checking if true
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment