Events Manager
[resolved] How to manually save Booking (4 posts)

  1. Oscar Estepa
    Posted 3 years ago #

    Hi I just read this thread:

    And I need to do exactly that, @Marcus your recommendation was:
    you need to also create a EM_Ticket_Booking object to associate the booking with a ticket for x spaces of that booking

    Could you explain further on how to do that?
    Many thanks


  2. agelonwl
    Posted 3 years ago #


    I think it's something like this

    $tickets_bookings_result = $EM_Booking->get_tickets_bookings()->save();
    //catch error
    if ( !$tickets_bookings_result  ){
  3. Oscar Estepa
    Posted 3 years ago #

    Thanks agelonwl, I found a solution which seems to be working fine for me:

    $EM_Person = new EM_Person($user_id);
    $EM_Event = new EM_Event($event_id);
    $EM_Tickets = $EM_Event->get_tickets();
    $EM_Booking = new EM_Booking();
    $EM_Tickets_Bookings = new EM_Tickets_Bookings($EM_Booking);
    $EM_Booking->event_id = $event_id;
    $EM_Booking->person_id = $user_id;
    $EM_Booking->booking_price = "0.00";
    $EM_Booking->booking_spaces = "1";
    $EM_Booking->booking_status = "0";
    $EM_Booking->person = $EM_Person;
    foreach ($EM_Tickets->tickets as $key => $EM_Ticket) {
        $EM_Ticket_Booking = new EM_Ticket_Booking();
        $EM_Ticket_Booking->ticket_id = $EM_Ticket->ticket_id;
        $EM_Ticket_Booking->ticket_booking_spaces = $EM_Booking->booking_spaces;
        $EM_Tickets_Bookings->tickets_bookings[$key] = $EM_Ticket_Booking;
    $EM_Booking->tickets_bookings = $EM_Tickets_Bookings;

    Maybe it's too much code just to save a booking, but in this way I'm making sure the $EM_Booking object has all the data required to be saved properly.

  4. agelonwl
    Posted 3 years ago #

    that seems to worked however maybe you can check this lines (for reference only) at events-manager/em-actions.php at around line 283 - 309

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Events Manager
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic