/** * creates buttons for selecting number of attendees for an event * * @access public * @param object $event * @param bool $view_details * @return string */ public static function display_ticket_selector($event = NULL, $view_details = FALSE) { // reset filter for displaying submit button remove_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); // poke and prod incoming event till it tells us what it is if (!EED_Ticket_Selector::set_event($event)) { return false; } $event_post = self::$_event instanceof EE_Event ? self::$_event->ID() : $event; // grab event status $_event_active_status = self::$_event->get_active_status(); if (!is_admin() && (!self::$_event->display_ticket_selector() || $view_details || post_password_required($event_post) || $_event_active_status != EE_Datetime::active && $_event_active_status != EE_Datetime::upcoming && $_event_active_status != EE_Datetime::sold_out && !($_event_active_status == EE_Datetime::inactive && is_user_logged_in()))) { return !is_single() ? EED_Ticket_Selector::display_view_details_btn() : ''; } $template_args = array(); $template_args['event_status'] = $_event_active_status; $template_args['date_format'] = apply_filters('FHEE__EED_Ticket_Selector__display_ticket_selector__date_format', get_option('date_format')); $template_args['time_format'] = apply_filters('FHEE__EED_Ticket_Selector__display_ticket_selector__time_format', get_option('time_format')); $template_args['EVT_ID'] = self::$_event->ID(); $template_args['event'] = self::$_event; // is the event expired ? $template_args['event_is_expired'] = self::$_event->is_expired(); if ($template_args['event_is_expired']) { return '<div class="ee-event-expired-notice"><span class="important-notice">' . __('We\'re sorry, but all tickets sales have ended because the event is expired.', 'event_espresso') . '</span></div>'; } $ticket_query_args = array(array('Datetime.EVT_ID' => self::$_event->ID()), 'order_by' => array('TKT_order' => 'ASC', 'TKT_required' => 'DESC', 'TKT_start_date' => 'ASC', 'TKT_end_date' => 'ASC', 'Datetime.DTT_EVT_start' => 'DESC')); if (!EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_expired_tickets) { //use the correct applicable time query depending on what version of core is being run. $current_time = method_exists('EEM_Datetime', 'current_time_for_query') ? time() : current_time('timestamp'); $ticket_query_args[0]['TKT_end_date'] = array('>', $current_time); } // get all tickets for this event ordered by the datetime $template_args['tickets'] = EEM_Ticket::instance()->get_all($ticket_query_args); if (count($template_args['tickets']) < 1) { return '<div class="ee-event-expired-notice"><span class="important-notice">' . __('We\'re sorry, but all ticket sales have ended.', 'event_espresso') . '</span></div>'; } // filter the maximum qty that can appear in the Ticket Selector qty dropdowns $template_args['max_atndz'] = apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector__max_tickets', self::$_event->additional_limit()); if ($template_args['max_atndz'] < 1) { $sales_closed_msg = __('We\'re sorry, but ticket sales have been closed at this time. Please check back again later.', 'event_espresso'); if (current_user_can('edit_post', self::$_event->ID())) { $sales_closed_msg .= sprintf(__('%sNote to Event Admin:%sThe "Maximum number of tickets allowed per order for this event" in the Event Registration Options has been set to "0". This effectively turns off ticket sales. %s(click to edit this event)%s', 'event_espresso'), '<div class="ee-attention" style="text-align: left;"><b>', '</b><br />', $link = '<span class="edit-link"><a class="post-edit-link" href="' . get_edit_post_link(self::$_event->ID()) . '">', '</a></span></div>'); } return '<p><span class="important-notice">' . $sales_closed_msg . '</span></p>'; } $templates['ticket_selector'] = TICKET_SELECTOR_TEMPLATES_PATH . 'ticket_selector_chart.template.php'; $templates['ticket_selector'] = apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector__template_path', $templates['ticket_selector'], self::$_event); // redirecting to another site for registration ?? $external_url = self::$_event->external_url() !== NULL || self::$_event->external_url() !== '' ? self::$_event->external_url() : FALSE; // set up the form (but not for the admin) $ticket_selector = !is_admin() ? EED_Ticket_Selector::ticket_selector_form_open(self::$_event->ID(), $external_url) : ''; // if not redirecting to another site for registration if (!$external_url) { // then display the ticket selector $ticket_selector .= EEH_Template::locate_template($templates['ticket_selector'], $template_args); } else { // if not we still need to trigger the display of the submit button add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); //display notice to admin that registration is external $ticket_selector .= !is_admin() ? '' : __('Registration is at an external URL for this event.', 'event_espresso'); } // submit button and form close tag $ticket_selector .= !is_admin() ? EED_Ticket_Selector::display_ticket_selector_submit() : ''; // set no cache headers and constants EE_System::do_not_cache(); return $ticket_selector; }
/** * _initialize - initial module setup * * @access private * @throws EE_Error * @return void */ private function _initialize() { // ensure SPCO doesn't run twice if (EED_Single_Page_Checkout::$_initialized) { return; } // setup the EE_Checkout object $this->checkout = $this->_initialize_checkout(); // filter checkout $this->checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize__checkout', $this->checkout); // get the $_GET $this->_get_request_vars(); // filter continue_reg $this->checkout->continue_reg = apply_filters('FHEE__EED_Single_Page_Checkout__init___continue_reg', TRUE, $this->checkout); // load the reg steps array if (!$this->_load_and_instantiate_reg_steps()) { EED_Single_Page_Checkout::$_initialized = true; return; } // set the current step $this->checkout->set_current_step($this->checkout->step); // and the next step $this->checkout->set_next_step(); // was there already a valid transaction in the checkout from the session ? if (!$this->checkout->transaction instanceof EE_Transaction) { // get transaction from db or session $this->checkout->transaction = $this->checkout->reg_url_link && !is_admin() ? $this->_get_transaction_and_cart_for_previous_visit() : $this->_get_cart_for_current_session_and_setup_new_transaction(); if (!$this->checkout->transaction instanceof EE_Transaction) { EE_Error::add_error(__('Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); // add some style and make it dance $this->checkout->transaction = EE_Transaction::new_instance(); $this->add_styles_and_scripts(); EED_Single_Page_Checkout::$_initialized = true; return; } // and the registrations for the transaction $this->_get_registrations($this->checkout->transaction); } // verify that everything has been setup correctly if (!$this->_final_verifications()) { EED_Single_Page_Checkout::$_initialized = true; return; } // lock the transaction $this->checkout->transaction->lock(); // make sure all of our cached objects are added to their respective model entity mappers $this->checkout->refresh_all_entities(); // set amount owing $this->checkout->amount_owing = $this->checkout->transaction->remaining(); // initialize each reg step, which gives them the chance to potentially alter the process $this->_initialize_reg_steps(); // DEBUG LOG //$this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ ); // get reg form $this->_check_form_submission(); // checkout the action!!! $this->_process_form_action(); // add some style and make it dance $this->add_styles_and_scripts(); // kk... SPCO has successfully run EED_Single_Page_Checkout::$_initialized = TRUE; // set no cache headers and constants EE_System::do_not_cache(); // add anchor add_action('loop_start', array($this, 'set_checkout_anchor'), 1); // remove transaction lock add_action('shutdown', array($this, 'unlock_transaction'), 1); }
/** * init * * @access public * @return void */ public function init() { $this->_get_reg_url_link(); if (!$this->get_txn()) { return NULL; } // if we've made it to the Thank You page, then let's toggle any "Failed" transactions to "Incomplete" if ($this->_current_txn->status_ID() == EEM_Transaction::failed_status_code) { $this->_current_txn->set_status(EEM_Transaction::incomplete_status_code); $this->_current_txn->save(); } $this->_primary_registrant = $this->_current_txn->primary_registration() instanceof EE_Registration ? $this->_current_txn->primary_registration() : NULL; $this->_is_primary = $this->_primary_registrant->reg_url_link() == $this->_reg_url_link ? TRUE : FALSE; $show_try_pay_again_link_default = apply_filters('AFEE__EES_Espresso_Thank_You__init__show_try_pay_again_link_default', TRUE); // txn status ? if ($this->_current_txn->is_completed()) { $this->_show_try_pay_again_link = $show_try_pay_again_link_default; } else { if ($this->_current_txn->is_incomplete() && ($this->_primary_registrant->is_approved() || $this->_primary_registrant->is_pending_payment())) { $this->_show_try_pay_again_link = TRUE; } else { if ($this->_primary_registrant->is_approved() || $this->_primary_registrant->is_pending_payment()) { // its pending $this->_show_try_pay_again_link = isset(EE_Registry::instance()->CFG->registration->show_pending_payment_options) && EE_Registry::instance()->CFG->registration->show_pending_payment_options ? TRUE : $show_try_pay_again_link_default; } else { $this->_show_try_pay_again_link = $show_try_pay_again_link_default; } } } $this->_payments_closed = !$this->_current_txn->payment_method() instanceof EE_Payment_Method ? TRUE : FALSE; $this->_is_offline_payment_method = $this->_current_txn->payment_method() instanceof EE_Payment_Method && $this->_current_txn->payment_method()->is_off_line() ? TRUE : FALSE; // link to SPCO $revisit_spco_url = add_query_arg(array('ee' => '_register', 'revisit' => TRUE, 'e_reg_url_link' => $this->_reg_url_link), EE_Registry::instance()->CFG->core->reg_page_url()); // link to SPCO payment_options $this->_SPCO_payment_options_url = $this->_primary_registrant instanceof EE_Registration ? $this->_primary_registrant->payment_overview_url() : add_query_arg(array('step' => 'payment_options'), $revisit_spco_url); // link to SPCO attendee_information $this->_SPCO_attendee_information_url = $this->_primary_registrant instanceof EE_Registration ? $this->_primary_registrant->edit_attendee_information_url() : FALSE; EE_Registry::instance()->load_helper('Template'); EE_Registry::instance()->load_helper('Template_Validator'); do_action('AHEE__EES_Espresso_Thank_You__init_end', $this->_current_txn); // set no cache headers and constants EE_System::do_not_cache(); }
/** * init * * @access public * @return void */ public function init() { $this->_get_reg_url_link(); if (!$this->get_txn()) { EE_Registry::instance()->load_helper('HTML'); echo EEH_HTML::div(EEH_HTML::h4(__('We\'re sorry...', 'event_espresso'), '', '') . sprintf(__('This is a system page for displaying transaction information after a purchase.%1$sYou are most likely seeing this notice because you have navigated to this page%1$sthrough some means other than completing a transaction.%1$sSorry for the disappointment, but you will most likely find nothing of interest here.%1$s%1$s', 'event_espresso'), '<br/>'), '', 'ee-attention'); return NULL; } // if we've made it to the Thank You page, then let's toggle any "Failed" transactions to "Incomplete" if ($this->_current_txn->status_ID() == EEM_Transaction::failed_status_code) { $this->_current_txn->set_status(EEM_Transaction::incomplete_status_code); $this->_current_txn->save(); } $this->_primary_registrant = $this->_current_txn->primary_registration() instanceof EE_Registration ? $this->_current_txn->primary_registration() : NULL; $this->_is_primary = $this->_primary_registrant->reg_url_link() == $this->_reg_url_link ? TRUE : FALSE; $show_try_pay_again_link_default = apply_filters('AFEE__EES_Espresso_Thank_You__init__show_try_pay_again_link_default', TRUE); // txn status ? if ($this->_current_txn->is_completed()) { $this->_show_try_pay_again_link = $show_try_pay_again_link_default; } else { if ($this->_current_txn->is_incomplete() && ($this->_primary_registrant->is_approved() || $this->_primary_registrant->is_pending_payment())) { $this->_show_try_pay_again_link = TRUE; } else { if ($this->_primary_registrant->is_approved() || $this->_primary_registrant->is_pending_payment()) { // its pending $this->_show_try_pay_again_link = isset(EE_Registry::instance()->CFG->registration->show_pending_payment_options) && EE_Registry::instance()->CFG->registration->show_pending_payment_options ? TRUE : $show_try_pay_again_link_default; } else { $this->_show_try_pay_again_link = $show_try_pay_again_link_default; } } } $this->_payments_closed = !$this->_current_txn->payment_method() instanceof EE_Payment_Method ? TRUE : FALSE; if (!$this->_current_txn->payment_method() instanceof EE_Payment_Method || $this->_current_txn->payment_method() instanceof EE_Payment_Method && $this->_current_txn->payment_method()->is_off_line()) { $this->_is_offline_payment_method = true; } else { $this->_is_offline_payment_method = false; } // link to SPCO $revisit_spco_url = add_query_arg(array('ee' => '_register', 'revisit' => TRUE, 'e_reg_url_link' => $this->_reg_url_link), EE_Registry::instance()->CFG->core->reg_page_url()); // link to SPCO payment_options $this->_SPCO_payment_options_url = $this->_primary_registrant instanceof EE_Registration ? $this->_primary_registrant->payment_overview_url() : add_query_arg(array('step' => 'payment_options'), $revisit_spco_url); // link to SPCO attendee_information $this->_SPCO_attendee_information_url = $this->_primary_registrant instanceof EE_Registration ? $this->_primary_registrant->edit_attendee_information_url() : FALSE; EE_Registry::instance()->load_helper('Template'); EE_Registry::instance()->load_helper('Template_Validator'); do_action('AHEE__EES_Espresso_Thank_You__init_end', $this->_current_txn); // set no cache headers and constants EE_System::do_not_cache(); }
/** * redirect_to_txn * * @access public * @return void */ public function redirect_to_txn() { EE_System::do_not_cache(); EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); $query_args = array('action' => 'view_transaction', 'TXN_ID' => isset($this->_req_data['TXN_ID']) ? absint($this->_req_data['TXN_ID']) : 0, 'page' => 'espresso_transactions'); if (isset($this->_req_data['EVT_ID'], $this->_req_data['redirect_from'])) { $query_args['EVT_ID'] = $this->_req_data['EVT_ID']; $query_args['event_name'] = urlencode($this->_req_data['event_name']); $query_args['redirect_from'] = $this->_req_data['redirect_from']; } EE_Error::add_success(__('Registration Created. Please review the transaction and add any payments as necessary', 'event_espresso')); $this->_redirect_after_action(false, '', '', $query_args, true); }