/** * run - initial shortcode module setup called during "wp_loaded" hook * this method is primarily used for loading resources that will be required by the shortcode when it is actually processed * * @access public * @param WP $WP * @return void */ public function run(WP $WP) { // SPCO is large and resource intensive, so it's better to do a double check before loading it up, so let's grab the post_content for the requested post global $wpdb; $SQL = 'SELECT post_content from ' . $wpdb->posts . ' WHERE post_type="page" AND post_status="publish" AND post_name=%s'; if ($post_content = $wpdb->get_var($wpdb->prepare($SQL, EE_Registry::instance()->REQ->get('post_name')))) { // now check for this shortcode if (strpos($post_content, '[ESPRESSO_CHECKOUT') !== FALSE) { if (!did_action('pre_get_posts')) { // this will trigger the EED_Events_Archive module's event_list() method during the pre_get_posts hook point, // this allows us to initialize things, enqueue assets, etc, // as well, this saves an instantiation of the module in an array using 'espresso_events' as the key, so that we can retrieve it add_action('pre_get_posts', array(EED_Single_Page_Checkout::instance(), 'run')); } else { global $wp; EED_Single_Page_Checkout::instance()->run($wp); } } } }
/** * process_reg_step * * @access public * @return string */ public function process_reg_step() { $this->_set_reg_event(); EE_Registry::instance()->REQ->set_espresso_page(TRUE); //what step are we on? $cart = EE_Registry::instance()->SSN->get_session_data('cart'); $step = empty($cart) ? 'ticket' : 'questions'; //if doing ajax then we need to verify the nonce if ('DOING_AJAX') { $nonce = isset($this->_req_data[$this->_req_nonce]) ? sanitize_text_field($this->_req_data[$this->_req_nonce]) : ''; $this->_verify_nonce($nonce, $this->_req_nonce); } switch ($step) { case 'ticket': //process ticket selection $success = EED_Ticket_Selector::instance()->process_ticket_selections(); if ($success) { EE_Error::add_success(__('Tickets Selected. Now complete the registration.'), 'event_espresso'); } else { $query_args['step_error'] = $this->_req_data['step_error'] = TRUE; } if (defined('DOING_AJAX')) { $this->new_registration(); //display next step } else { $query_args['action'] = 'new_registration'; $query_args['processing_registration'] = true; $query_args['event_id'] = $this->_reg_event->ID(); $this->_redirect_after_action(FALSE, '', '', $query_args, TRUE); } break; case 'questions': if (!isset($this->_req_data['txn_reg_status_change'], $this->_req_data['txn_reg_status_change']['send_notifications'])) { add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_false', 15); } //process registration $transaction = EED_Single_Page_Checkout::instance()->process_registration_from_admin(); if (!$transaction instanceof EE_Transaction) { $query_args = array('action' => 'new_registration', 'processing_registration' => true, 'event_id' => $this->_reg_event->ID()); if (defined('DOING_AJAX')) { //display registration form again because there are errors (maybe validation?) $this->new_registration(); return; } else { $this->_redirect_after_action(FALSE, '', '', $query_args, TRUE); return; } } /** @type EE_Transaction_Payments $transaction_payments */ $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments'); // maybe update status, and make sure to save transaction if not done already if (!$transaction_payments->update_transaction_status_based_on_total_paid($transaction)) { $transaction->save(); } $query_args = array('action' => 'view_transaction', 'TXN_ID' => $transaction->ID(), 'page' => 'espresso_transactions'); 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); break; } //what are you looking here for? Should be nothing to do at this point. }
/** * run * * @access public * @param WP_Query $WP_Query * @return void */ public static function init($WP_Query) { EED_Single_Page_Checkout::instance()->run($WP_Query); }
/** * _process_registration_step * * @access public * @return string */ public function _process_registration_step() { $this->_set_reg_event(); EE_Registry::instance()->REQ->set_espresso_page(TRUE); //what step are we on? $cart = EE_Registry::instance()->SSN->get_session_data('cart'); $step = empty($cart) ? 'ticket' : 'questions'; //if doing ajax then we need to verify the nonce if ('DOING_AJAX') { $nonce = isset($this->_req_data[$this->_req_nonce]) ? sanitize_text_field($this->_req_data[$this->_req_nonce]) : ''; $this->_verify_nonce($nonce, $this->_req_nonce); } switch ($step) { case 'ticket': //process ticket selection $success = EED_Ticket_Selector::instance()->process_ticket_selections(); if ($success) { EE_Error::add_success(__('Tickets Selected. Now complete the registration.'), 'event_espresso'); } else { $query_args['step_error'] = $this->_req_data['step_error'] = TRUE; } if (defined('DOING_AJAX')) { $this->new_registration(); //display next step } else { $query_args['action'] = 'new_registration'; $query_args['processing_registration'] = true; $query_args['event_id'] = $this->_reg_event->ID(); $this->_redirect_after_action(FALSE, '', '', $query_args, TRUE); } break; case 'questions': //process registration $TXN_ID = EED_Single_Page_Checkout::instance()->process_registration_from_admin(); if (!$TXN_ID) { $query_args = array('action' => 'new_registration', 'processing_registration' => true, 'event_id' => $this->_reg_event->ID()); if (defined('DOING_AJAX')) { $this->new_registration(); //display registration form again because there are errors (maybe validation?) } else { $this->_redirect_after_action(FALSE, '', '', $query_args, TRUE); } } $query_args = array('action' => 'view_transaction', 'TXN_ID' => $TXN_ID, 'page' => 'espresso_transactions'); 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); break; } //what are you looking here for? Should be nothing to do at this point. }
public static function process_payment_options() { $SPCO = EED_Single_Page_Checkout::instance(); if ($SPCO instanceof EED_Single_Page_Checkout) { $SPCO->_current_step = 'payment_options'; $SPCO->init(); $SPCO->_process_payment_options(); } }