/**
  *  refresh_entity_map
  *  simply loops through the current transaction and updates
  *  each model's entity map using EEM_Base::refresh_entity_map_with()
  *
  * @access public
  * @return bool
  */
 protected function refresh_entity_map()
 {
     // verify the transaction
     if ($this->transaction instanceof EE_Transaction && $this->transaction->ID()) {
         // never cache payment info
         $this->transaction->clear_cache('Payment');
         /** @type EE_Transaction_Processor $transaction_processor */
         $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
         // is the Payment Options Reg Step completed ?
         if ($transaction_processor->reg_step_completed($this->transaction, 'payment_options')) {
             // then check for payments and update TXN accordingly
             /** @type EE_Transaction_Payments $transaction_payments */
             $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
             $transaction_payments->calculate_total_payments_and_update_status($this->transaction);
         }
         // grab the saved registrations from the transaction
         foreach ($this->transaction->registrations($this->reg_cache_where_params) as $reg_cache_ID => $registration) {
             $this->_refresh_registration($reg_cache_ID, $registration);
         }
         // make sure our cached TXN is added to the model entity mapper
         $this->transaction = $this->transaction->get_model()->refresh_entity_map_with($this->transaction->ID(), $this->transaction);
     } else {
         EE_Error::add_error(__('A valid Transaction was not found when attempting to update the model entity mapper.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
         return FALSE;
     }
     if ($this->cart instanceof EE_Cart) {
         $grand_total = $this->cart->get_grand_total();
         if ($grand_total instanceof EE_Line_Item && $grand_total->ID()) {
             $grand_total = $grand_total->get_model()->refresh_entity_map_with($this->cart->get_grand_total()->ID(), $this->cart->get_grand_total());
         }
         if ($grand_total instanceof EE_Line_Item) {
             $this->cart = EE_Cart::instance($grand_total);
         } else {
             EE_Error::add_error(__('A valid Cart was not found when attempting to update the model entity mapper.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
             return false;
         }
     }
     return TRUE;
 }
 /**
  * _get_cart_for_transaction
  *
  * @access private
  * @param EE_Transaction $transaction
  * @return EE_Cart
  */
 private function _get_cart_for_transaction($transaction)
 {
     $cart = $transaction instanceof EE_Transaction ? EE_Cart::get_cart_from_txn($transaction) : NULL;
     // verify cart
     if (!$cart instanceof EE_Cart) {
         $cart = EE_Registry::instance()->load_core('Cart');
     }
     return $cart;
 }
 /**
  * _get_cart_for_current_session_and_setup_new_transaction
  * 	generates a new EE_Transaction object and adds it to the $_transaction property.
  *
  * 	@access public
  * @param EE_Transaction $transaction
  * 	@return EE_Cart
  */
 public function get_cart_for_transaction(EE_Transaction $transaction)
 {
     return EE_Cart::get_cart_from_txn($transaction);
 }
 /**
  * _validate_return
  *
  * @access private
  * @return bool
  */
 private function _validate_offsite_return()
 {
     $TXN_ID = (int) EE_Registry::instance()->REQ->get('spco_txn', 0);
     if ($TXN_ID != $this->checkout->transaction->ID()) {
         // Houston... we might have a problem
         $invalid_TXN = false;
         // first gather some info
         $valid_TXN = EEM_Transaction::instance()->get_one_by_ID($TXN_ID);
         $primary_registrant = $valid_TXN instanceof EE_Transaction ? $valid_TXN->primary_registration() : null;
         // let's start by retrieving the cart for this TXN
         $cart = EE_Cart::get_cart_from_txn($this->checkout->transaction);
         if ($cart instanceof EE_Cart) {
             // verify that the current cart has tickets
             $tickets = $cart->get_tickets();
             if (empty($tickets)) {
                 $invalid_TXN = true;
             }
         } else {
             $invalid_TXN = true;
         }
         $valid_TXN_SID = $primary_registrant instanceof EE_Registration ? $primary_registrant->session_ID() : null;
         // validate current Session ID and compare against valid TXN session ID
         if (EE_Session::instance()->id() === null) {
             $invalid_TXN = true;
         } else {
             if (EE_Session::instance()->id() === $valid_TXN_SID) {
                 // WARNING !!!
                 // this could be PayPal sending back duplicate requests (ya they do that)
                 // or it **could** mean someone is simply registering AGAIN after having just done so
                 // so now we need to determine if this current TXN looks valid or not
                 /** @type EE_Transaction_Processor $transaction_processor */
                 $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
                 // has this step even been started ?
                 if ($transaction_processor->reg_step_completed($this->checkout->transaction, $this->slug() === false)) {
                     // really? you're half way through this reg step, but you never started it ?
                     $invalid_TXN = true;
                 }
             }
         }
         if ($invalid_TXN) {
             // is the valid TXN completed ?
             if ($valid_TXN instanceof EE_Transaction) {
                 /** @type EE_Transaction_Processor $transaction_processor */
                 $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
                 // has this step even been started ?
                 $reg_step_completed = $transaction_processor->reg_step_completed($valid_TXN, $this->slug());
                 if ($reg_step_completed !== false && $reg_step_completed !== true) {
                     // so it **looks** like this is a double request from PayPal
                     // so let's try to pick up where we left off
                     $this->checkout->transaction = $valid_TXN;
                     $this->checkout->refresh_all_entities(true);
                     return;
                 }
             }
             // you appear to be lost?
             $this->_redirect_wayward_request($primary_registrant);
         }
     }
 }
 protected function _setup_data()
 {
     //need to figure out the running total for test purposes so... we're going to create a temp cart and add the tickets to it!
     EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
     $cart = EE_Cart::reset();
     //add tickets to cart
     foreach ($this->tickets as $ticket) {
         $cart->add_ticket_to_cart($ticket['ticket']);
     }
     //setup txn property
     $this->txn = EE_Transaction::new_instance(array('TXN_timestamp' => time(), 'TXN_total' => 0, 'TXN_paid' => 0, 'STS_ID' => EEM_Transaction::incomplete_status_code, 'TXN_session_data' => NULL, 'TXN_hash_salt' => NULL, 'TXN_ID' => 999999));
     //setup reg_objects
     //note we're setting up a reg object for each attendee in each event but ALSO adding to the reg_object array.
     $this->reg_objs = array();
     $regid = 9999990;
     foreach ($this->_attendees as $key => $attendee) {
         //note we need to setup reg_objects for each event this attendee belongs to
         $regatt = $attendee['att_obj']->ID();
         $regtxn = $this->txn->ID();
         $regcnt = 1;
         foreach ($attendee['line_ref'] as $evtid) {
             foreach ($this->_events[$evtid]['tkt_objs'] as $ticket) {
                 $reg_array = array('EVT_ID' => $evtid, 'ATT_ID' => $regatt, 'TXN_ID' => $regtxn, 'TKT_ID' => $ticket->ID(), 'STS_ID' => EEM_Registration::status_id_pending_payment, 'REG_date' => time(), 'REG_final_price' => $ticket->get('TKT_price'), 'REG_session' => 'dummy_session_id', 'REG_code' => $regid . '-dummy-generated-code', 'REG_url_link' => $regcnt . '-daafpapasdlfakasdfpqasdfasdf', 'REG_count' => $regcnt, 'REG_group_size' => $this->_events[$evtid]['total_attendees'], 'REG_att_is_going' => TRUE, 'REG_ID' => $regid);
                 $REG_OBJ = EE_Registration::new_instance($reg_array);
                 $this->_attendees[$key]['reg_objs'][$regid] = $REG_OBJ;
                 $this->_events[$evtid]['reg_objs'][] = $REG_OBJ;
                 $this->reg_objs[] = $REG_OBJ;
                 $this->tickets[$ticket->ID()]['reg_objs'][$regid] = $REG_OBJ;
                 $regcnt++;
                 $regid++;
             }
         }
     }
     //setup line items!
     EE_Registry::instance()->load_helper('Line_Item');
     $line_item_total = EEH_Line_Item::create_total_line_item($this->txn);
     //add tickets
     foreach ($this->tickets as $tktid => $item) {
         $qty = $item['count'];
         $ticket = $item['ticket'];
         EEH_Line_Item::add_ticket_purchase($line_item_total, $ticket, $qty);
     }
     $shipping_line_item = EE_Line_Item::new_instance(array('LIN_name' => __('Shipping Surcharge', 'event_espresso'), 'LIN_desc' => __('Sent via Millenium Falcon', 'event_espresso'), 'LIN_unit_price' => 20, 'LIN_quantity' => 1, 'LIN_is_taxable' => TRUE, 'LIN_total' => 20, 'LIN_type' => EEM_Line_Item::type_line_item));
     EEH_Line_Item::add_item($line_item_total, $shipping_line_item);
     $this->additional_line_items = array($shipping_line_item);
     //now let's add taxes
     EEH_Line_Item::apply_taxes($line_item_total);
     //now we should be able to get the items we need from this object
     $event_line_items = EEH_Line_Item::get_pre_tax_subtotal($line_item_total)->children();
     $line_items = array();
     foreach ($event_line_items as $line_id => $line_item) {
         if (!$line_item instanceof EE_Line_Item || $line_item->OBJ_type() !== 'Event') {
             continue;
         }
         $ticket_line_items = EEH_Line_Item::get_ticket_line_items($line_item);
         foreach ($ticket_line_items as $ticket_line_id => $ticket_line_item) {
             if (!$ticket_line_item instanceof EE_Line_Item) {
                 continue;
             }
             $this->tickets[$ticket_line_item->OBJ_ID()]['line_item'] = $ticket_line_item;
             $this->tickets[$ticket_line_item->OBJ_ID()]['sub_line_items'] = $ticket_line_item->children();
             $line_items[$ticket_line_item->ID()]['children'] = $ticket_line_item->children();
             $line_items[$ticket_line_item->ID()]['EE_Ticket'] = $this->tickets[$ticket_line_item->OBJ_ID()]['ticket'];
         }
     }
     $this->line_items_with_children = $line_items;
     $this->tax_line_items = $line_item_total->tax_descendants();
     //add proper total to transaction object.
     $grand_total = $line_item_total->recalculate_total_including_taxes();
     $this->grand_total_line_item = $line_item_total;
     $this->txn->set_total($grand_total);
     //add additional details for each registration
     foreach ($this->reg_objs as $reg) {
         $this->_registrations[$reg->ID()]['tkt_obj'] = $this->tickets[$reg->get('TKT_ID')]['ticket'];
         $this->_registrations[$reg->ID()]['evt_obj'] = $this->_events[$reg->get('EVT_ID')]['event'];
         $this->_registrations[$reg->ID()]['reg_obj'] = $reg;
         $this->_registrations[$reg->ID()]['ans_objs'] = $this->_attendees[$reg->get('ATT_ID')]['ans_objs'];
         $this->_registrations[$reg->ID()]['att_obj'] = $this->_attendees[$reg->get('ATT_ID')]['att_obj'];
         $this->_registrations[$reg->ID()]['dtt_objs'] = $this->tickets[$reg->get('TKT_ID')]['dtt_objs'];
     }
     //events and attendees
     $this->events = $this->_events;
     $this->attendees = $this->_attendees;
     $this->registrations = $this->_registrations;
     $attendees_to_shift = $this->_attendees;
     //setup primary attendee property
     $this->primary_attendee_data = array('fname' => $this->_attendees[999999991]['att_obj']->fname(), 'lname' => $this->_attendees[999999991]['att_obj']->lname(), 'email' => $this->_attendees[999999991]['att_obj']->email(), 'att_obj' => $this->_attendees[999999991]['att_obj'], 'reg_obj' => array_shift($attendees_to_shift[999999991]['reg_objs']));
     //reg_info property
     //note this isn't referenced by any shortcode parsers so we'll ignore for now.
     $this->reg_info = array();
     //let's set a reg_obj for messengers expecting one.
     $this->reg_obj = array_pop($this->_attendees[999999991]['reg_objs']);
     //the below are just dummy items.
     $this->user_id = 1;
     $this->ip_address = '192.0.2.1';
     $this->user_agent = '';
     $this->init_access = time();
     $this->last_access = time();
 }
 /**
  *    get_cart_from_reg_url_link
  * @access public
  * @param EE_Transaction $transaction
  * @return \EE_Cart
  */
 public static function get_cart_from_txn(EE_Transaction $transaction)
 {
     $grand_total = $transaction->total_line_item();
     $grand_total->get_items();
     $grand_total->tax_descendants();
     return EE_Cart::instance($grand_total);
 }
 protected function _setup_data()
 {
     //need to figure out the running total for test purposes so... we're going to create a temp cart and add the tickets to it!
     EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
     $cart = EE_Cart::instance();
     //add tickets to cart
     foreach ($this->tickets as $ticket) {
         $cart->add_ticket_to_cart($ticket['ticket']);
     }
     $grand_total = $cart->get_cart_grand_total() * count($this->_attendees);
     //EEH_Template::format_currency($cart->get_grand_total(), true);
     //setup billing property
     //todo:  I'm only using this format for the array because its how the gateways currently setup this data.  I HATE IT and it needs fixed but I have no idea how many places in the code this data structure currently touches.  Once its fixed we'll have to fix it here and in the shortcode parsing where this particular property is accessed.  (See https://events.codebasehq.com/projects/event-espresso/tickets/2271) for related ticket.
     $this->billing = array('first name' => 'Luke', 'last name' => 'Skywalker', 'email address' => '*****@*****.**', 'address' => '804 Bantha Dr.', 'city' => 'Mos Eisley', 'state' => 'Section 7', 'country' => 'Tatooine', 'zip' => 'f0r3e', 'ccv code' => 'xxx', 'credit card #' => '999999xxxxxxxx', 'expiry date' => '12 / 3000', 'total_due' => $grand_total);
     //setup txn property
     $this->txn = EE_Transaction::new_instance(array('TXN_timestamp' => current_time('mysql'), 'TXN_total' => $grand_total, 'TXN_paid' => $grand_total, 'STS_ID' => EEM_Transaction::incomplete_status_code, 'TXN_session_data' => NULL, 'TXN_hash_salt' => NULL, 'TXN_ID' => 999999));
     //setup reg_objects
     //note we're setting up a reg object for each attendee in each event but ALSO adding to the reg_object array.
     $this->reg_objs = array();
     $regid = 9999990;
     foreach ($this->_attendees as $key => $attendee) {
         //note we need to setup reg_objects for each event this attendee belongs to
         $regatt = $attendee['att_obj']->ID();
         $regtxn = $this->txn->ID();
         $regcnt = 1;
         foreach ($attendee['line_ref'] as $evtid) {
             foreach ($this->_events[$evtid]['tkt_objs'] as $ticket) {
                 $reg_array = array('EVT_ID' => $evtid, 'ATT_ID' => $regatt, 'TXN_ID' => $regtxn, 'TKT_ID' => $ticket->ID(), 'STS_ID' => EEM_Registration::status_id_pending_payment, 'REG_date' => current_time('mysql'), 'REG_final_price' => $ticket->get('TKT_price'), 'REG_session' => 'dummy_session_id', 'REG_code' => $regid . '-dummy_generated_reg_code', 'REG_url_link' => '#', 'REG_count' => $regcnt, 'REG_group_size' => $this->_events[$evtid]['total_attendees'], 'REG_att_is_going' => TRUE, 'REG_ID' => $regid);
                 $REG_OBJ = EE_Registration::new_instance($reg_array);
                 $this->_attendees[$key]['reg_obj'][$regid] = $REG_OBJ;
                 $this->_events[$evtid]['reg_objs'][] = $REG_OBJ;
                 $this->reg_objs[] = $REG_OBJ;
                 $regcnt++;
                 $regid++;
             }
         }
     }
     //add additional details for each registration
     foreach ($this->reg_objs as $reg) {
         $this->_registrations[$reg->ID()]['tkt_obj'] = $this->tickets[$reg->get('TKT_ID')]['ticket'];
         $this->_registrations[$reg->ID()]['evt_obj'] = $this->_events[$reg->get('EVT_ID')]['event'];
         $this->_registrations[$reg->ID()]['reg_obj'] = $reg;
         $this->_registrations[$reg->ID()]['ans_objs'] = $this->_attendees[$reg->get('ATT_ID')]['ans_objs'];
         $this->_registrations[$reg->ID()]['att_obj'] = $this->_attendees[$reg->get('ATT_ID')]['att_obj'];
         $this->_registrations[$reg->ID()]['dtt_objs'] = $this->tickets[$reg->get('TKT_ID')]['dtt_objs'];
     }
     //events and attendees
     $this->events = $this->_events;
     $this->attendees = $this->_attendees;
     $this->registrations = $this->_registrations;
     //setup primary attendee property
     $this->primary_attendee_data = array('fname' => $this->_attendees[999999991]['att_obj']->fname(), 'lname' => $this->_attendees[999999991]['att_obj']->lname(), 'email' => $this->_attendees[999999991]['att_obj']->email(), 'att_obj' => $this->_attendees[999999991]['att_obj'], 'reg_obj' => $this->_attendees[999999991]['reg_obj']);
     //reg_info property
     //note this isn't referenced by any shortcode parsers so we'll ignore for now.
     $this->reg_info = array();
     //the below are just dummy items.
     $this->user_id = 1;
     $this->ip_address = '192.0.2.1';
     $this->user_agent = '';
     $this->init_access = current_time('mysql');
     $this->last_access = current_time('mysql');
 }
 public function test_save_cart()
 {
     $t2 = $this->new_typical_transaction(array('ticket_types' => 2));
     $cart = EE_Cart::get_cart_from_txn($t2);
     EE_Registry::instance()->SSN->reset_data(array('cart'));
     $this->assertNotEquals(EE_Registry::instance()->SSN->get_session_data('cart'), $cart);
     $cart->save_cart();
     $this->assertEquals(EE_Registry::instance()->SSN->get_session_data('cart'), $cart);
 }
 /**
  *        remove all events from the event cart
  *
  * @access        public
  * @return        void
  */
 public function empty_event_cart()
 {
     $this->init();
     EED_Multi_Event_Registration::load_classes();
     // remove all unwanted records from the db
     if (EE_Registry::instance()->CART->delete_cart()) {
         // and clear the session too
         EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
         // reset cached cart
         EE_Registry::instance()->CART = EE_Cart::instance(null);
         if (apply_filters('FHEE__EED_Multi_Event_Registration__display_success_messages', false)) {
             EE_Error::add_success(sprintf(__('The %1$s was successfully emptied!', 'event_espresso'), EED_Multi_Event_Registration::$event_cart_name), __FILE__, __FUNCTION__, __LINE__);
         }
     } else {
         EE_Error::add_error(sprintf(__('The %1$s could not be emptied!', 'event_espresso'), EED_Multi_Event_Registration::$event_cart_name), __FILE__, __FUNCTION__, __LINE__);
     }
     $this->send_ajax_response(true, apply_filters('FHEE__EED_Multi_Event_Registration__empty_event_cart__redirect_url', EE_EVENTS_LIST_URL));
 }
 /**
  * 	init - initial module setup
  *
  *  @access 	public
  *  @return 	void
  */
 public function init()
 {
     // add no cache headers
     add_action('wp_head', array('EED_Single_Page_Checkout', 'nocache_headers'), 10);
     // plus a little extra for nginx
     add_filter('nocache_headers', array('EED_Single_Page_Checkout', 'nocache_headers_nginx'), 10, 1);
     // prevent browsers from prefetching of the rel='next' link, because it may contain content that interferes with the registration process
     remove_action('wp_head', 'adjacent_posts_rel_link_wp_head');
     // load classes
     if (!isset(EE_Registry::instance()->REQ)) {
         EE_Registry::instance()->load_core('Request_Handler');
     }
     EE_Registry::instance()->REQ->set_espresso_page(TRUE);
     //		printr( EE_Registry::instance()->REQ, 'EE_Registry::instance()->REQ  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
     // make sure reg steps array is setup
     if (empty(self::$_reg_steps)) {
         EED_Single_Page_Checkout::setup_reg_steps_array();
     }
     $this->_continue_reg = apply_filters('FHEE__EED_Single_Page_Checkout__init___continue_reg', TRUE);
     $this->set_templates();
     $this->_reg_page_base_url = get_permalink(EE_Registry::instance()->CFG->core->reg_page_id);
     // grab what step we're on
     $this->_current_step = !empty($this->_current_step) ? $this->_current_step : 'attendee_information';
     $this->_current_step = EE_Registry::instance()->REQ->is_set('step') ? EE_Registry::instance()->REQ->get('step') : $this->_current_step;
     // returning from the thank you page ?
     $this->_reg_url_link = EE_Registry::instance()->REQ->is_set('e_reg_url_link') ? EE_Registry::instance()->REQ->get('e_reg_url_link') : FALSE;
     // if reg_url_link is present in the request, then we are only being sent back to SPCO to retry the payment
     if ($this->_reg_url_link) {
         // are we returning to the page to edit attendee info or retry a payment?
         $this->_revisit = EE_Registry::instance()->REQ->is_set('revisit') && EE_Registry::instance()->REQ->get('revisit') == 1 ? TRUE : FALSE;
         if ($this->_revisit) {
             // remove all other pages from the reg steps array except the one required by the revisit
             self::$_reg_steps = array_intersect_key(self::$_reg_steps, array($this->_current_step => TRUE));
         }
         // let's get that transaction data
         $this->_transaction = EE_Registry::instance()->load_model('Transaction')->get_transaction_from_reg_url_link();
         //			printr( $this->_transaction, 'transaction_from_reg_url_link  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
         //			d( $this->_transaction );
         // verify transaction
         if ($this->_transaction instanceof EE_Transaction) {
             //				d( $this->_transaction );
             // and get the cart that was used in the original txn
             $this->_cart = EE_Cart::get_cart_from_txn($this->_transaction);
             //				if (  $this->_transaction instanceof EE_Transaction && $this->_revisit ) {
             $registrations = $this->_transaction->registrations(array(), TRUE);
             usort($registrations, array('EED_Single_Page_Checkout', 'sort_registrations_by_REG_count'));
             foreach ($registrations as $registration) {
                 //d( $registration );
                 // verify registration
                 if ($registration instanceof EE_Registration) {
                     // we display all attendee info for the primary registrant
                     if ($this->_reg_url_link == $registration->reg_url_link() && $registration->is_primary_registrant()) {
                         $this->_primary_revisit = TRUE;
                         break;
                     } else {
                         if ($this->_reg_url_link != $registration->reg_url_link()) {
                             // but hide info if it doesn't belong to you
                             $this->_transaction->clear_cache('Registration', $registration->ID());
                         }
                     }
                 }
             }
             //				}
         } else {
             EE_Error::add_error(__('Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
         }
     } else {
         $this->_transaction = EE_Registry::instance()->SSN->get_session_data('transaction');
         //			printr( $this->_transaction, '$this->_transaction <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
         $this->_cart = EE_Registry::instance()->load_core('Cart');
         //			printr( $this->_transaction->registrations(), '$this->_transaction->registrations()  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
     }
     // verify cart
     if (!$this->_cart instanceof EE_Cart) {
         $this->_cart = EE_Registry::instance()->load_core('Cart');
     }
     // verify transaction
     if ($this->_transaction instanceof EE_Transaction) {
         //printr( $this->_transaction->registrations(), '$transaction->registrations() <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
         $ID = $this->_transaction->ID();
         if (!$this->_revisit && $ID) {
             // but if this transaction has already been saved to the db earlier in the same session (ie: it's not a revisit)... then let's pull that
             if (!($this->_transaction = EEM_Transaction::instance()->get_one_by_ID($ID))) {
                 EE_Error::add_error(__('The Transaction could not be retrieved from the db when attempting to process your registration information', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
                 return;
             }
         }
     } elseif (!$this->_revisit) {
         $this->_initialize_transaction();
     } else {
     }
     // and verify registrations have been set (first check cached REGs)
     if ($this->_transaction instanceof EE_Transaction && $this->_transaction->registrations(array(), TRUE) == NULL) {
         // then check the db
         if ($this->_transaction->registrations() == NULL) {
             $this->_initialize_registrations();
         }
     }
     // don't need payment options for a completed transaction (note: if we ever implement donations, then this will need overriding)
     if ($this->_transaction->is_completed() || $this->_transaction->is_overpaid()) {
         unset(self::$_reg_steps['payment_options']);
     }
     // and the next step
     $this->_set_next_step();
     // load css and js
     add_action('wp_enqueue_scripts', array('EED_Single_Page_Checkout', 'load_css'), 10);
     add_action('wp_enqueue_scripts', array('EED_Single_Page_Checkout', 'load_js'), 10);
 }
예제 #11
0
 /**
  *	@save cart to session
  *	@access public
  *	@return TRUE on success, FALSE on fail
  */
 public function save_cart()
 {
     self::$_instance->_apply_taxes_to_total();
     return EE_Registry::instance()->SSN->set_session_data(array('cart' => self::$_instance));
 }
 /**
  *    _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());
 }