/**
  *   verify_tickets_in_cart
  * compares the current tickets in the cart with the current registrations for the checkout's transaction.
  * if any difference between the type of ticket or their associated quantities exist,
  * then registrations will be added or removed accordingly.
  *
  * @access public
  * @param \EE_Checkout $checkout
  * @return \EE_Checkout
  */
 public static function verify_tickets_in_cart(EE_Checkout $checkout)
 {
     // verify transaction
     if ($checkout->transaction instanceof EE_Transaction) {
         $changes = false;
         EED_Multi_Event_Registration::load_classes();
         // first we need to get an accurate list of tickets in the cart
         $cart_tickets = EED_Multi_Event_Registration::get_tickets_in_cart($checkout);
         // then we need to get an accurate list of registration tickets
         $registrations = $checkout->transaction->registrations();
         $reg_tickets = EED_Multi_Event_Registration::get_registration_tickets($registrations);
         // now delete registrations for any tickets that were completely removed
         foreach ($reg_tickets as $reg_ticket_id => $reg_ticket_registrations) {
             if (!isset($cart_tickets[$reg_ticket_id])) {
                 foreach ($reg_ticket_registrations as $reg_ticket_registration) {
                     $changes = EED_Multi_Event_Registration::remove_registration($checkout->transaction, $reg_ticket_registration) ? true : $changes;
                 }
             }
         }
         // then add new tickets and/or adjust quantities for others
         foreach ($cart_tickets as $TKT_ID => $ticket_line_items) {
             $changes = EED_Multi_Event_Registration::adjust_registration_quantities($checkout->transaction, $TKT_ID, $ticket_line_items, $reg_tickets) ? true : $changes;
         }
         if ($changes) {
             $new_ticket_count = count($checkout->transaction->registrations());
             EED_Multi_Event_Registration::reset_registration_details($checkout->transaction, $new_ticket_count);
             EED_Multi_Event_Registration::update_cart($checkout);
             EED_Multi_Event_Registration::update_checkout_and_transaction($checkout, $new_ticket_count);
             add_filter('FHEE__Single_Page_Checkout__load_reg_steps__reload_reg_steps', '__return_true');
         }
     }
     return $checkout;
 }