Empty cart before adding new tickets

Home Forums Ticket Products Event Tickets Plus Empty cart before adding new tickets

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #1604433
    dylankiss
    Participant

    Hello,

    I have a website for a theater, where I’d like to limit the customers to buying tickets for only event at a time.
    So I was thinking to empty the cart before tickets are added from the tickets form on an event page.
    Can I hook into the process right before the tickets are added to the cart?
    I can’t seem to find where this is happening.

    Thanks in advance!

    Best regards,
    Dylan

    #1604568
    dylankiss
    Participant

    Hi again,

    After searching further, I found the process_front_end_tickets_form function in event-tickets-plus/src/Tribe/Commerce/WooCommerce/Main.php. Since I didn’t find any hook in there, I attached my function to the same wp_loaded action, but with an earlier priority. It seems to be working fine.

    
    add_action( 'wp_loaded', 'clear_cart_after_submitting_ticket_form', 10 );
    
    function clear_cart_after_submitting_ticket_form() {
      global $woocommerce;
      if ( empty( $_REQUEST['wootickets_process'] ) || intval( $_REQUEST['wootickets_process'] ) !== 1 || empty( $_POST['product_id'] ) ) {
    	return;
      }
      $woocommerce->cart->empty_cart();
    }
    
    #1606568

    Glad to hear it, you are welcome back in our support forums any time!

    Since this issue has been resolved, I am going to close this thread.

    Have a great week!

Viewing 3 posts - 1 through 3 (of 3 total)
  • The topic ‘Empty cart before adding new tickets’ is closed to new replies.