Hi. How can we help?

How to add event ticket status on order details page on customer site

In this way, your customers can see the event ticket status on order details page
You need to add the following code on functions.php

if( class_exists( 'YITH_Tickets' ) ) {
if (!function_exists('yith_wcevti_woocommerce_order_item_meta_end_event_ticket')) {
function yith_wcevti_woocommerce_order_item_meta_end_event_ticket($item_id, $item, $order, $status)
{

$product = wc_get_product($item['product_id']);

if ($product && 'ticket-event' == $product->get_type()) {

$event_id = wc_get_order_item_meta($item_id, '_event_id', true);
$ticket_status = get_post_status( $event_id );

$ticket_status = empty($ticket_status) ? 'yith-wcevti-pending-check' : $ticket_status;
if ('yi-checked' == $ticket_status) {
?>
Ticket status: <span class="ticket_status_icon fa fa-thumbs-o-up status_checked"
title="Checked"></span>
<?php
} elseif ('yi-cancelled' == $ticket_status) {
?>
Ticket status: <span class="ticket_status_icon fa fa-ban status_cancelled" title="Cancelled"></span>
<?php
} else {
?>
Ticket status: <span class="ticket_status_icon fa fa-hand-paper-o status_pending_check"
title="Pending check"></span>
<?php
}
}

}

add_action('woocommerce_order_item_meta_end', 'yith_wcevti_woocommerce_order_item_meta_end_event_ticket', 999, 4);
}
}

Also, you need to add the following CSS rule on Appearance > Customize > Additional CSS

.status_checked{
background: #2ea2cc;
padding: 0.3em;
border-radius: 15px;
}
.status_pending_check{
background: #73a724;
padding: 0.3em;
border-radius: 15px;
}
.status_cancelled {
background: #a00;
padding: 0.3em;
border-radius: 15px;
}

You obtain the result showed in the followed image:

2019-03-20_1107.png

Was this article helpful?
1 out of 1 found this helpful

Back to Help Center >