/**
  * _display_payment_options
  *
  * @param string $transaction_details
  * @return \EE_Form_Section_Proper
  */
 private function _display_payment_options($transaction_details = '')
 {
     // has method_of_payment been set by no-js user?
     $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment();
     // build payment options form
     return apply_filters('FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__payment_options_form', new EE_Form_Section_Proper(array('subsections' => array('before_payment_options' => apply_filters('FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__before_payment_options', new EE_Form_Section_Proper(array('layout_strategy' => new EE_Div_Per_Section_Layout()))), 'payment_options' => $this->_setup_payment_options(), 'after_payment_options' => apply_filters('FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__after_payment_options', new EE_Form_Section_Proper(array('layout_strategy' => new EE_Div_Per_Section_Layout()))), 'default_hidden_inputs' => $this->reg_step_hidden_inputs(), 'extra_hidden_inputs' => $this->_extra_hidden_inputs(FALSE)), 'layout_strategy' => new EE_Template_Layout(array('layout_template_file' => $this->_template, 'template_args' => apply_filters('FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__template_args', array('reg_count' => $this->line_item_display->total_items(), 'transaction_details' => $transaction_details, 'available_payment_methods' => array())))))));
 }
 /**
  * @return EE_Form_Section_Proper
  */
 public function generate_reg_form()
 {
     $this->_print_copy_info = FALSE;
     $primary_registrant = NULL;
     // autoload Line_Item_Display classes
     EEH_Autoloader::register_line_item_display_autoloaders();
     $Line_Item_Display = new EE_Line_Item_Display();
     // calculate taxes
     $Line_Item_Display->display_line_item($this->checkout->cart->get_grand_total(), array('set_tax_rate' => true));
     EE_Registry::instance()->load_helper('Line_Item');
     /** @var $subsections EE_Form_Section_Proper[] */
     $subsections = array('default_hidden_inputs' => $this->reg_step_hidden_inputs());
     $template_args = array('revisit' => $this->checkout->revisit, 'registrations' => array(), 'ticket_count' => array());
     // grab the saved registrations from the transaction
     $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params);
     if ($registrations) {
         foreach ($registrations as $registration) {
             if ($registration instanceof EE_Registration) {
                 // can this registration be processed during this visit ?
                 if ($this->checkout->visit_allows_processing_of_this_registration($registration)) {
                     $subsections[$registration->reg_url_link()] = $this->_registrations_reg_form($registration);
                     if (!$this->checkout->admin_request) {
                         $template_args['registrations'][$registration->reg_url_link()] = $registration;
                         $template_args['ticket_count'][$registration->ticket()->ID()] = isset($template_args['ticket_count'][$registration->ticket()->ID()]) ? $template_args['ticket_count'][$registration->ticket()->ID()] + 1 : 1;
                         $ticket_line_item = EEH_Line_Item::get_line_items_by_object_type_and_IDs($this->checkout->cart->get_grand_total(), 'Ticket', array($registration->ticket()->ID()));
                         $ticket_line_item = is_array($ticket_line_item) ? reset($ticket_line_item) : $ticket_line_item;
                         $template_args['ticket_line_item'][$registration->ticket()->ID()] = $Line_Item_Display->display_line_item($ticket_line_item);
                     }
                     if ($registration->is_primary_registrant()) {
                         $primary_registrant = $registration->reg_url_link();
                     }
                 }
             }
         }
         // print_copy_info ?
         if ($primary_registrant && count($registrations) > 1 && !$this->checkout->admin_request) {
             // TODO: add admin option for toggling copy attendee info, then use that value to change $this->_print_copy_info
             $copy_options['spco_copy_attendee_chk'] = $this->_print_copy_info ? $this->_copy_attendee_info_form() : $this->_auto_copy_attendee_info();
             // generate hidden input
             if (isset($subsections[$primary_registrant]) && $subsections[$primary_registrant] instanceof EE_Form_Section_Proper) {
                 $subsections[$primary_registrant]->add_subsections($copy_options, 'primary_registrant', false);
             }
         }
     }
     return new EE_Form_Section_Proper(array('name' => $this->reg_form_name(), 'html_id' => $this->reg_form_name(), 'subsections' => $subsections, 'layout_strategy' => $this->checkout->admin_request ? new EE_Div_Per_Section_Layout() : new EE_Template_Layout(array('layout_template_file' => $this->_template, 'template_args' => $template_args))));
 }
 /**
  * _display_payment_options
  *
  * @param string $transaction_details
  * @return \EE_Form_Section_Proper
  */
 private function _display_payment_options($transaction_details = '')
 {
     // reset in case someone changes their mind
     $this->_reset_selected_method_of_payment();
     // has method_of_payment been set by no-js user?
     $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment();
     // build payment options form
     return new EE_Form_Section_Proper(array('subsections' => array('payment_options' => $this->_setup_payment_options(), 'default_hidden_inputs' => $this->reg_step_hidden_inputs(), 'extra_hidden_inputs' => $this->_extra_hidden_inputs(FALSE)), 'layout_strategy' => new EE_Template_Layout(array('layout_template_file' => SPCO_TEMPLATES_PATH . $this->slug() . DS . 'payment_options_main.template.php', 'template_args' => apply_filters('FHEE__EE_SPCO_Reg_Step_Payment_Options___payment_options__template_args', array('reg_count' => $this->Line_Item_Display->total_items(), 'transaction_details' => $transaction_details, 'available_payment_methods' => array()))))));
 }
 /**
  * 		generates HTML for the Registration main meta box
  *		@access public
  *		@return void
  */
 public function _reg_details_meta_box()
 {
     EEH_Autoloader::register_line_item_display_autoloaders();
     EEH_Autoloader::register_line_item_filter_autoloaders();
     EE_Registry::instance()->load_Helper('Line_Item');
     $transaction = $this->_registration->transaction() ? $this->_registration->transaction() : EE_Transaction::new_instance();
     $this->_session = $transaction->session_data();
     $filters = new EE_Line_Item_Filter_Collection();
     $filters->add(new EE_Single_Registration_Line_Item_Filter($this->_registration));
     $filters->add(new EE_Non_Zero_Line_Item_Filter());
     $line_item_filter_processor = new EE_Line_Item_Filter_Processor($filters, $transaction->total_line_item());
     $filtered_line_item_tree = $line_item_filter_processor->process();
     $this->_template_args['REG_ID'] = $this->_registration->ID();
     $line_item_display = new EE_Line_Item_Display('reg_admin_table', 'EE_Admin_Table_Registration_Line_Item_Display_Strategy');
     $this->_template_args['line_item_table'] = $line_item_display->display_line_item($filtered_line_item_tree, array('EE_Registration' => $this->_registration));
     $attendee = $this->_registration->attendee();
     $this->_template_args['view_transaction_button'] = EE_Registry::instance()->CAP->current_user_can('ee_read_transaction', 'espresso_transactions_view_transaction') ? EEH_Template::get_button_or_link(EE_Admin_Page::add_query_args_and_nonce(array('action' => 'view_transaction', 'TXN_ID' => $transaction->ID()), TXN_ADMIN_URL), __(' View Transaction'), 'button secondary-button right', 'dashicons dashicons-cart') : '';
     $this->_template_args['resend_registration_button'] = $attendee instanceof EE_Attendee && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'espresso_registrations_resend_registration') ? EEH_Template::get_button_or_link(EE_Admin_Page::add_query_args_and_nonce(array('action' => 'resend_registration', '_REG_ID' => $this->_registration->ID(), 'redirect_to' => 'view_registration'), REG_ADMIN_URL), __(' Resend Registration'), 'button secondary-button right', 'dashicons dashicons-email-alt') : '';
     $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
     $payment = $transaction->get_first_related('Payment');
     $payment = !$payment instanceof EE_Payment ? EE_Payment::new_instance() : $payment;
     $payment_method = $payment->get_first_related('Payment_Method');
     $payment_method = !$payment_method instanceof EE_Payment_Method ? EE_Payment_Method::new_instance() : $payment_method;
     $reg_status_class = 'status-' . $this->_registration->status_ID();
     $reg_details = array('payment_method' => $payment_method->name(), 'response_msg' => $payment->gateway_response(), 'registration_id' => $this->_registration->get('REG_code'), 'registration_session' => $this->_registration->session_ID(), 'ip_address' => isset($this->_session['ip_address']) ? $this->_session['ip_address'] : '', 'user_agent' => isset($this->_session['user_agent']) ? $this->_session['user_agent'] : '');
     if (isset($reg_details['registration_id'])) {
         $this->_template_args['reg_details']['registration_id']['value'] = $reg_details['registration_id'];
         $this->_template_args['reg_details']['registration_id']['label'] = __('Registration ID', 'event_espresso');
         $this->_template_args['reg_details']['registration_id']['class'] = 'regular-text';
     }
     if (isset($reg_details['payment_method'])) {
         $this->_template_args['reg_details']['payment_method']['value'] = $reg_details['payment_method'];
         $this->_template_args['reg_details']['payment_method']['label'] = __('Most Recent Payment Method', 'event_espresso');
         $this->_template_args['reg_details']['payment_method']['class'] = 'regular-text';
         $this->_template_args['reg_details']['response_msg']['value'] = $reg_details['response_msg'];
         $this->_template_args['reg_details']['response_msg']['label'] = __('Payment method response', 'event_espresso');
         $this->_template_args['reg_details']['response_msg']['class'] = 'regular-text';
     }
     $this->_template_args['reg_details']['registration_session']['value'] = $reg_details['registration_session'];
     $this->_template_args['reg_details']['registration_session']['label'] = __('Registration Session', 'event_espresso');
     $this->_template_args['reg_details']['registration_session']['class'] = 'regular-text';
     $this->_template_args['reg_details']['ip_address']['value'] = $reg_details['ip_address'];
     $this->_template_args['reg_details']['ip_address']['label'] = __('Registration placed from IP', 'event_espresso');
     $this->_template_args['reg_details']['ip_address']['class'] = 'regular-text';
     $this->_template_args['reg_details']['user_agent']['value'] = $reg_details['user_agent'];
     $this->_template_args['reg_details']['user_agent']['label'] = __('Registrant User Agent', 'event_espresso');
     $this->_template_args['reg_details']['user_agent']['class'] = 'large-text';
     $this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'default', 'event_id' => $this->_registration->event_ID()), REG_ADMIN_URL);
     $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_details.template.php';
     echo EEH_Template::display_template($template_path, $this->_template_args, TRUE);
 }
 /**
  *    _get_event_cart
  *
  * @access        protected
  * @param \EE_Line_Item $line_item
  * @return string
  * @throws \EE_Error
  */
 protected function _get_event_cart($line_item = null)
 {
     $line_item = $line_item instanceof EE_Line_Item ? $line_item : EE_Registry::instance()->CART->get_grand_total();
     // autoload Line_Item_Display classes
     EEH_Autoloader::register_line_item_display_autoloaders();
     $Line_Item_Display = new EE_Line_Item_Display('event_cart', 'EE_Event_Cart_Line_Item_Display_Strategy');
     if (!$Line_Item_Display instanceof EE_Line_Item_Display && WP_DEBUG) {
         throw new EE_Error(__('A valid instance of EE_Event_Cart_Line_Item_Display_Strategy could not be obtained.', 'event_espresso'));
     }
     return $Line_Item_Display->display_line_item($line_item);
 }
 /**
  * txn_details_meta_box
  * generates HTML for the Transaction main meta box
  *
  * @access public
  *	@return void
  */
 public function txn_details_meta_box()
 {
     $this->_set_transaction_object();
     $this->_template_args['TXN_ID'] = $this->_transaction->ID();
     $this->_template_args['attendee'] = $this->_transaction->primary_registration() instanceof EE_Registration ? $this->_transaction->primary_registration()->attendee() : null;
     //get line table
     EEH_Autoloader::register_line_item_display_autoloaders();
     $Line_Item_Display = new EE_Line_Item_Display('admin_table', 'EE_Admin_Table_Line_Item_Display_Strategy');
     $this->_template_args['line_item_table'] = $Line_Item_Display->display_line_item($this->_transaction->total_line_item());
     $this->_template_args['REG_code'] = $this->_transaction->get_first_related('Registration')->get('REG_code');
     // process taxes
     $taxes = $this->_transaction->get_many_related('Line_Item', array(array('LIN_type' => EEM_Line_Item::type_tax)));
     $this->_template_args['taxes'] = !empty($taxes) ? $taxes : FALSE;
     $this->_template_args['grand_total'] = EEH_Template::format_currency($this->_transaction->get('TXN_total'), FALSE, FALSE);
     $this->_template_args['grand_raw_total'] = $this->_transaction->get('TXN_total');
     $this->_template_args['TXN_status'] = $this->_transaction->get('STS_ID');
     //		$txn_status_class = 'status-' . $this->_transaction->get('STS_ID');
     // process payment details
     $payments = $this->_transaction->get_many_related('Payment');
     if (!empty($payments)) {
         $this->_template_args['payments'] = $payments;
         $this->_template_args['existing_reg_payments'] = $this->_get_registration_payment_IDs($payments);
     } else {
         $this->_template_args['payments'] = false;
         $this->_template_args['existing_reg_payments'] = array();
     }
     $this->_template_args['edit_payment_url'] = add_query_arg(array('action' => 'edit_payment'), TXN_ADMIN_URL);
     $this->_template_args['delete_payment_url'] = add_query_arg(array('action' => 'espresso_delete_payment'), TXN_ADMIN_URL);
     if (isset($txn_details['invoice_number'])) {
         $this->_template_args['txn_details']['invoice_number']['value'] = $this->_template_args['REG_code'];
         $this->_template_args['txn_details']['invoice_number']['label'] = __('Invoice Number', 'event_espresso');
     }
     $this->_template_args['txn_details']['registration_session']['value'] = $this->_transaction->get_first_related('Registration')->get('REG_session');
     $this->_template_args['txn_details']['registration_session']['label'] = __('Registration Session', 'event_espresso');
     $this->_template_args['txn_details']['ip_address']['value'] = isset($this->_session['ip_address']) ? $this->_session['ip_address'] : '';
     $this->_template_args['txn_details']['ip_address']['label'] = __('Transaction placed from IP', 'event_espresso');
     $this->_template_args['txn_details']['user_agent']['value'] = isset($this->_session['user_agent']) ? $this->_session['user_agent'] : '';
     $this->_template_args['txn_details']['user_agent']['label'] = __('Registrant User Agent', 'event_espresso');
     $reg_steps = '<ul>';
     foreach ($this->_transaction->reg_steps() as $reg_step => $reg_step_status) {
         if ($reg_step_status === true) {
             $reg_steps .= '<li style="color:#70cc50">' . sprintf(__('%1$s : Completed', 'event_espresso'), ucwords(str_replace('_', ' ', $reg_step))) . '</li>';
         } else {
             if (is_numeric($reg_step_status) && $reg_step_status !== false) {
                 $reg_steps .= '<li style="color:#2EA2CC">' . sprintf(__('%1$s : Initiated %2$s', 'event_espresso'), ucwords(str_replace('_', ' ', $reg_step)), gmdate(get_option('date_format') . ' ' . get_option('time_format'), $reg_step_status + get_option('gmt_offset') * HOUR_IN_SECONDS)) . '</li>';
             } else {
                 $reg_steps .= '<li style="color:#E76700">' . sprintf(__('%1$s : Never Initiated', 'event_espresso'), ucwords(str_replace('_', ' ', $reg_step))) . '</li>';
             }
         }
     }
     $reg_steps .= '</ul>';
     $this->_template_args['txn_details']['reg_steps']['value'] = $reg_steps;
     $this->_template_args['txn_details']['reg_steps']['label'] = __('Registration Step Progress', 'event_espresso');
     $this->_get_registrations_to_apply_payment_to();
     $this->_get_payment_methods($payments);
     $this->_get_payment_status_array();
     $this->_get_reg_status_selection();
     //sets up the template args for the reg status array for the transaction.
     $this->_template_args['transaction_form_url'] = add_query_arg(array('action' => 'edit_transaction', 'process' => 'transaction'), TXN_ADMIN_URL);
     $this->_template_args['apply_payment_form_url'] = add_query_arg(array('page' => 'espresso_transactions', 'action' => 'espresso_apply_payment'), WP_AJAX_URL);
     $this->_template_args['delete_payment_form_url'] = add_query_arg(array('page' => 'espresso_transactions', 'action' => 'espresso_delete_payment'), WP_AJAX_URL);
     // 'espresso_delete_payment_nonce'
     $template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_main_meta_box_txn_details.template.php';
     echo EEH_Template::display_template($template_path, $this->_template_args, TRUE);
 }
 /**
  *    get_event_cart
  *
  * @access public
  * @param string $template
  * @return string
  * @throws \EE_Error
  */
 public function get_mini_cart($template = '')
 {
     switch ($template) {
         case EE_MER_PATH . 'templates' . DS . 'widget_minicart_list.template.php':
             $minicart_line_item_display_strategy = 'EE_Mini_Cart_List_Line_Item_Display_Strategy';
             break;
         case EE_MER_PATH . 'templates' . DS . 'widget_minicart_table.template.php':
         default:
             $minicart_line_item_display_strategy = 'EE_Mini_Cart_Table_Line_Item_Display_Strategy';
             break;
     }
     EEH_Autoloader::register_autoloader(array($minicart_line_item_display_strategy => EE_MER_PATH . $minicart_line_item_display_strategy . '.php'));
     // autoload Line_Item_Display classes
     EEH_Autoloader::register_line_item_display_autoloaders();
     $Line_Item_Display = new EE_Line_Item_Display('event_cart', apply_filters('FHEE__EEW_Mini_Cart__widget__minicart_line_item_display_strategy', $minicart_line_item_display_strategy));
     if (!$Line_Item_Display instanceof EE_Line_Item_Display && WP_DEBUG) {
         throw new EE_Error(__('A valid instance of EE_Event_Cart_Line_Item_Display_Strategy could not be obtained.', 'event_espresso'));
     }
     return $Line_Item_Display->display_line_item(EE_Registry::instance()->CART->get_grand_total());
 }
 /**
  *    _get_payment_info
  *
  * @access    public
  * @param EE_Cart $cart
  * @return    array
  */
 public function _get_payment_info(EE_Cart $cart)
 {
     EEH_Autoloader::register_line_item_filter_autoloaders();
     $line_item_filter_processor = new EE_Line_Item_Filter_Processor(apply_filters('FHEE__SPCO__EE_Line_Item_Filter_Collection', new EE_Line_Item_Filter_Collection()), $cart->get_grand_total());
     $filtered_line_item_tree = $line_item_filter_processor->process();
     // autoload Line_Item_Display classes
     EEH_Autoloader::register_line_item_display_autoloaders();
     //$this->checkout->line_item_filters();
     $Line_Item_Display = new EE_Line_Item_Display('spco');
     return array('payment_info' => $Line_Item_Display->display_line_item($filtered_line_item_tree), 'cart_total' => $filtered_line_item_tree->total());
 }