/** * _save_registration_attendee * * @param EE_Registration $registration * @param bool $show_errors * @return void */ private function _save_registration($registration, $show_errors = TRUE) { // verify object if ($registration instanceof EE_Registration) { // should this registration be processed during this visit ? if ($this->visit_allows_processing_of_this_registration($registration)) { //set TXN ID if (!$registration->transaction_ID()) { $registration->set_transaction_id($this->transaction->ID()); } // verify and save the attendee $this->_save_registration_attendee($registration, $show_errors); // save answers to reg form questions $this->_save_registration_answers($registration, $show_errors); // save changes $registration->save(); // update txn cache if (!$this->transaction->update_cache_after_object_save('Registration', $registration)) { if ($show_errors) { EE_Error::add_error(__('The newly saved Registration object could not be cached on the Transaction.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); } } } } else { if ($show_errors) { EE_Error::add_error(__('An invalid Registration object was discovered when attempting to save your registration information.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); } } }
/** * _save_all_registration_information * simply loops through the current transaction and saves all data for each registration * * @access private * @return bool */ private function _save_all_registration_information() { // echo '<br/><h5 style="color:#2EA2CC;">'. __CLASS__ . '<span style="font-weight:normal;color:#0074A2"> -> </span>' . __FUNCTION__ . '() <br/><span style="font-size:9px;font-weight:normal;color:#666">' . __FILE__ . '</span> <b style="font-size:10px;color:#333"> ' . __LINE__ . ' </b></h5>'; // verify the transaction if ($this->_transaction instanceof EE_Transaction) { $this->_transaction->save(); // grab the saved registrations from the transaction foreach ($this->_transaction->registrations(array(), TRUE) as $line_item_id => $registration) { // // printr( $registration, '$registration <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); // verify object if ($registration instanceof EE_Registration) { // if the event's default_registration_status is set to "Approved", then make sure it's set as such if ($registration->event()->default_registration_status() == EEM_Registration::status_id_approved) { $registration->set_status(EEM_Registration::status_id_approved); } // if this is a revisit OR first visit and event is NOT sold out if ($this->_revisit || !$this->_revisit && !($registration->event()->is_sold_out() || $registration->event()->is_sold_out(TRUE))) { // EITHER a) first time thru SPCO so process ALL registrations // OR b) primary registrant is editing info, so process ALL registrations // OR b) another registrant is editing info, so ONLY process their registration if (!$this->_revisit || $this->_primary_revisit || $this->_revisit && $this->_reg_url_link == $registration->reg_url_link()) { //set TXN ID if (!$registration->transaction_ID()) { $registration->set_transaction_id($this->_transaction->ID()); } // verify and save the attendee $attendee = $registration->attendee(); if ($attendee) { if ($attendee instanceof EE_Attendee) { // printr( $attendee, '$attendee <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); $attendee->save(); // echo '<h5 style="color:#2EA2CC;">$attendee->ID() : <span style="color:#E76700">' . $attendee->ID() . '</span><br/><span style="font-size:9px;font-weight:normal;color:#666">' . __FILE__ . '</span> <b style="font-size:10px;color:#333"> ' . __LINE__ . ' </b></h5>'; $registration->set_attendee_id($attendee->ID()); if (!$registration->update_cache_after_object_save('Attendee', $attendee)) { EE_Error::add_error(__('The newly saved Attendee object could not be cached on the registration.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); return FALSE; } } else { EE_Error::add_error(__('An invalid Attendee object was discovered when attempting to save your registration information.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); return FALSE; } } else { EE_Error::add_error(__('No Attendee object was found when attempting to save your registration information.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); return FALSE; } // save so that REG has ID $registration->save(); // echo '<h5 style="color:#2EA2CC;">$registration->ID() : <span style="color:#E76700">' . $registration->ID() . '</span><br/><span style="font-size:9px;font-weight:normal;color:#666">' . __FILE__ . '</span> <b style="font-size:10px;color:#333"> ' . __LINE__ . ' </b></h5>'; // now save the answers foreach ($registration->answers() as $cache_key => $answer) { // echo '<h5 style="color:#2EA2CC;">$cache_key : <span style="color:#E76700">' . $cache_key . '</span><br/><span style="font-size:9px;font-weight:normal;color:#666">' . __FILE__ . '</span> <b style="font-size:10px;color:#333"> ' . __LINE__ . ' </b></h5>'; // echo '<h5 style="color:#2EA2CC;">$answer->question()->display_text() : <span style="color:#E76700">' . $answer->question()->display_text() . '</span><br/><span style="font-size:9px;font-weight:normal;color:#666">' . __FILE__ . '</span> <b style="font-size:10px;color:#333"> ' . __LINE__ . ' </b></h5>'; // echo '<h5 style="color:#2EA2CC;">$answer->value() : <span style="color:#E76700">' . $answer->value() . '</span><br/><span style="font-size:9px;font-weight:normal;color:#666">' . __FILE__ . '</span> <b style="font-size:10px;color:#333"> ' . __LINE__ . ' </b></h5>'; // verify object if ($answer instanceof EE_Answer) { // printr( $answer, '$answer <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); $answer->set_registration($registration->ID()); $answer->save(); // echo '<h5 style="color:#2EA2CC;">$answer->ID() : <span style="color:#E76700">' . $answer->ID() . '</span><br/><span style="font-size:9px;font-weight:normal;color:#666">' . __FILE__ . '</span> <b style="font-size:10px;color:#333"> ' . __LINE__ . ' </b></h5>'; if (!$registration->update_cache_after_object_save('Answer', $answer, $cache_key)) { EE_Error::add_error(__('The newly saved Answer object could not be cached on the registration.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); return FALSE; } } else { EE_Error::add_error(__('An invalid Answer object was discovered when attempting to save your registration information.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); return FALSE; } } if (!$this->_transaction->update_cache_after_object_save('Registration', $registration, $line_item_id)) { EE_Error::add_error(__('The newly saved Registration object could not be cached on the Transaction.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); return FALSE; } } } else { EE_Error::add_error(apply_filters('FHEE__Single_Page_Checkout___save_all_registration_information__sold_out_events_msg', __('It appears that the event you are attempting to register for has just sold out. If you have already made a partial payment towards this event, please contact the event administrator for a refund.', 'event_espresso')), __FILE__, __FUNCTION__, __LINE__); return FALSE; } } else { EE_Error::add_error(__('An invalid Registration object was discovered when attempting to save your registration information.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); return FALSE; } } } else { EE_Error::add_error(__('A valid Transaction was not found when attempting to save your registration information.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); return FALSE; } return TRUE; }