Tribe__Tickets_Plus__Commerce__WooCommerce__Main::validate_tickets()
If a user saves a ticket in their cart and after a few hours / days the ticket is still on the cart but the ticket has expired or is no longer available for sales the item on the cart shouldn’t be processed.
Instead of removing the product from the cart we send a notice and avoid to checkout so the user knows exactly why can move forward and he needs to take an action before doing so.
Return
(bool)
Source
File: src/Tribe/Commerce/WooCommerce/Main.php
public function validate_tickets() {
foreach ( WC()->cart->get_cart() as $cart_item_key => $values ) {
$product_id = empty( $values['product_id'] ) ? null : $values['product_id'];
if ( is_null( $product_id ) ) {
continue;
}
$ticket_type = Tribe__Tickets__Tickets::load_ticket_object( $product_id );
if ( ! $ticket_type || ! $ticket_type instanceof Tribe__Tickets__Ticket_Object ) {
continue;
}
if ( ! $ticket_type->date_in_range() ) {
$message = sprintf(
__( 'The ticket: %1$s, in your cart is no longer available or valid. You need to remove it from your cart in order to continue.', 'event-tickets-plus' ),
$ticket_type->name
);
wc_add_notice( $message, 'error' );
return false;
}
}
return true;
}
Changelog
| Version | Description |
|---|---|
| 4.7.3 | Introduced. |