Hi Victor,
Apologies, I was actually looking at the wrong thing. The ticket_id is correct, but the _tribe_wooticket_order_item which is saved as meta value for that ticket is incorrect.
This happens with either this code:
$wooticket = get_posts( array(
'post_type' => 'tribe_wooticket',
'meta_key' => '_unique_id',
'meta_value' => $ticket['ticket_id'],
'posts_per_page' => 1
) );
if ( !$wooticket ) {
// Some more detailed error logging here.
error_log( 'error' );
}
$oiid = get_post_meta( $wooticket[0]->ID, '_tribe_wooticket_order_item', true ); // <-- this is where I get the wrong value
$oi = new WC_Order_Item_Product( $oiid );
and also with this:
$oi = new WC_Order_Item_Product( $ticket['order_item_id'] );
(all being inside the [theme]/tribe-events/tickets/email.php template)
($ticket in both cases is one element of the $tickets[] array provided to the template by event tickets plus)
Workflow to reproduce this issue 100%:
- Add ticket to cart
- Checkout to PayPal
- Cancel on the PayPal site, get redirected to shopping cart
- Checkout to PayPal again
- Complete Paypal Payment
I always get an ID that’s too low (594 when it should be 596)