当前位置: 首页>>代码示例>>PHP>>正文


PHP EE_Transaction::_add_relation_to方法代码示例

本文整理汇总了PHP中EE_Transaction::_add_relation_to方法的典型用法代码示例。如果您正苦于以下问题:PHP EE_Transaction::_add_relation_to方法的具体用法?PHP EE_Transaction::_add_relation_to怎么用?PHP EE_Transaction::_add_relation_to使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EE_Transaction的用法示例。


在下文中一共展示了EE_Transaction::_add_relation_to方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _initialize_registrations

 /**
  * 	adds related EE_Registration objects for each ticket in the cart to the current EE_Transaction object
  *
  * 	@access private
  * 	@return 	void
  */
 private function _initialize_registrations()
 {
     if ($this->_transaction instanceof EE_Transaction) {
         $att_nmbr = 0;
         $total_items = $this->_cart->all_ticket_quantity_count();
         // now let's add the cart items to the $transaction
         foreach ($this->_cart->get_tickets() as $item) {
             // grab the related ticket object for this line_item
             $ticket = $item->ticket();
             if (!$ticket instanceof EE_Ticket) {
                 EE_Error::add_error(sprintf(__("Line item %s did not contain a valid ticket", "event_espresso"), $item->ID()), __FILE__, __FUNCTION__, __LINE__);
                 break;
             }
             $first_datetime = $ticket->get_first_related('Datetime');
             if (!$first_datetime instanceof EE_Datetime) {
                 EE_Error::add_error(sprintf(__("The ticket (%s) is not associated with any valid datetimes.", "event_espresso"), $ticket->name()), __FILE__, __FUNCTION__, __LINE__);
                 continue;
             }
             $event = $first_datetime->get_first_related('Event');
             if (!$event instanceof EE_Event) {
                 EE_Error::add_error(sprintf(__("The ticket (%s) is not associated with a valid event.", "event_espresso"), $ticket->name()), __FILE__, __FUNCTION__, __LINE__);
                 continue;
             }
             //do the following for each ticket of this type they selected
             for ($x = 1; $x <= $item->quantity(); $x++) {
                 $att_nmbr++;
                 $reg_url_link = $att_nmbr . '-' . $item->code();
                 // grab the default reg status for the event
                 $registration_status = $event->default_registration_status();
                 // if it's set to "Approved", then temporarily downgrade it to "Pending Payment", so that reg limits and/or ticket sales are not skewed in case the reg process is aborted
                 $registration_status = $registration_status == EEM_Registration::status_id_approved ? EEM_Registration::status_id_pending_payment : $registration_status;
                 try {
                     // now create a new registration for the ticket
                     $registration = EE_Registration::new_instance(array('EVT_ID' => $event->ID(), 'TXN_ID' => $this->_transaction->ID(), 'TKT_ID' => $ticket->ID(), 'STS_ID' => $registration_status, 'REG_date' => $this->_transaction->datetime(), 'REG_final_price' => $ticket->price(), 'REG_session' => EE_Registry::instance()->SSN->id(), 'REG_count' => $att_nmbr, 'REG_group_size' => $total_items, 'REG_url_link' => $reg_url_link));
                     // now create relations between various objects
                     $registration->_add_relation_to($event, 'Event', array(), $event->ID());
                     $registration->_add_relation_to($item->ticket(), 'Ticket', array(), $item->ticket()->ID());
                     $this->_transaction->_add_relation_to($registration, 'Registration', array(), $reg_url_link);
                     // if something failed...
                 } catch (Exception $e) {
                     EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
                     return;
                 }
             }
         }
         EE_Registry::instance()->SSN->set_session_data(array('transaction' => $this->_transaction));
         EE_Registry::instance()->SSN->update();
         //			echo '<h3>'. __CLASS__ . '->' . __FUNCTION__ . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h3>';
     }
     return;
 }
开发者ID:antares-ff,项目名称:ANTARES-Test,代码行数:57,代码来源:EED_Single_Page_Checkout.module.php

示例2: generate_ONE_registration_from_line_item

 /**
  * generate_ONE_registration_from_line_item
  *
  * Although a ticket line item may have a quantity greater than 1,
  * this method will ONLY CREATE ONE REGISTRATION !!!
  * Regardless of the ticket line item quantity.
  * This means that any code calling this method is responsible for ensuring
  * that the final registration count matches the ticket line item quantity.
  * This was done to make it easier to match the number of registrations
  * to the number of tickets in the cart, when the cart has been edited
  * after SPCO has already been initialized. So if an additional ticket was added to the cart, you can simply pass
  * the line item to this method to add a second ticket, and in this case, you would not want to add 2 tickets.
  *
  * @param EE_Line_Item $line_item
  * @param \EE_Transaction $transaction
  * @param int $att_nmbr
  * @param int $total_ticket_count
  * @return \EE_Registration | null
  * @throws \EE_Error
  */
 public function generate_ONE_registration_from_line_item(EE_Line_Item $line_item, EE_Transaction $transaction, $att_nmbr = 1, $total_ticket_count = 1)
 {
     // grab the related ticket object for this line_item
     $ticket = $line_item->ticket();
     if (!$ticket instanceof EE_Ticket) {
         EE_Error::add_error(sprintf(__("Line item %s did not contain a valid ticket", "event_espresso"), $line_item->ID()), __FILE__, __FUNCTION__, __LINE__);
         return null;
     }
     $first_datetime = $ticket->get_first_related('Datetime');
     if (!$first_datetime instanceof EE_Datetime) {
         EE_Error::add_error(sprintf(__("The ticket (%s) is not associated with any valid datetimes.", "event_espresso"), $ticket->name()), __FILE__, __FUNCTION__, __LINE__);
         return null;
     }
     $event = $first_datetime->get_first_related('Event');
     if (!$event instanceof EE_Event) {
         EE_Error::add_error(sprintf(__("The ticket (%s) is not associated with a valid event.", "event_espresso"), $ticket->name()), __FILE__, __FUNCTION__, __LINE__);
         return null;
     }
     $reg_url_link = $this->generate_reg_url_link($att_nmbr, $line_item);
     if ($this->_reg_final_price_per_tkt_line_item === null) {
         $this->_reg_final_price_per_tkt_line_item = EEH_Line_Item::calculate_reg_final_prices_per_line_item($transaction->total_line_item());
     }
     //ok now find this new registration's final price
     if (isset($this->_reg_final_price_per_tkt_line_item[$line_item->ID()])) {
         $final_price = $this->_reg_final_price_per_tkt_line_item[$line_item->ID()];
     } else {
         $message = sprintf(__('The ticket line item (ID:%1$d) had no entry in the reg_final_price_per_tkt_line_item array.', 'event_espresso'), $line_item->ID());
         if (WP_DEBUG) {
             throw new EE_Error($message);
         } else {
             EE_Log::instance()->log(__CLASS__, __FUNCTION__, $message);
         }
         $final_price = $ticket->get_ticket_total_with_taxes();
     }
     // now create a new registration for the ticket
     $registration = EE_Registration::new_instance(array('EVT_ID' => $event->ID(), 'TXN_ID' => $transaction->ID(), 'TKT_ID' => $ticket->ID(), 'STS_ID' => EEM_Registration::status_id_incomplete, 'REG_date' => $transaction->datetime(), 'REG_final_price' => $final_price, 'REG_session' => EE_Registry::instance()->SSN->id(), 'REG_count' => $att_nmbr, 'REG_group_size' => $total_ticket_count, 'REG_url_link' => $reg_url_link));
     $registration->set_reg_code($this->generate_reg_code($registration));
     $registration->save();
     $registration->_add_relation_to($event, 'Event', array(), $event->ID());
     $registration->_add_relation_to($line_item->ticket(), 'Ticket', array(), $line_item->ticket()->ID());
     $transaction->_add_relation_to($registration, 'Registration');
     return $registration;
 }
开发者ID:DavidSteinbauer,项目名称:event-espresso-core,代码行数:63,代码来源:EE_Registration_Processor.class.php

示例3: reset_registration_details

 /**
  *   reset_registration_reg_counts
  *
  * @access protected
  * @param EE_Transaction $transaction
  * @param int $total_ticket_count
  * @return void
  */
 protected static function reset_registration_details(EE_Transaction $transaction, $total_ticket_count = 0)
 {
     $att_nmbr = 0;
     /** @type EE_Registration_Processor $registration_processor */
     $registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
     $registrations = $transaction->registrations();
     uasort($registrations, array('EED_Multi_Event_Registration', 'sort_registrations_by_reg_count_callback'));
     foreach ($registrations as $registration) {
         if ($registration instanceof EE_Registration) {
             $att_nmbr++;
             $registration->set_count($att_nmbr);
             $registration->set_group_size($total_ticket_count);
             $reg_url_bits = explode('-', $registration->reg_url_link());
             $reg_url_link = $att_nmbr . '-' . end($reg_url_bits);
             $registration->set_reg_url_link($reg_url_link);
             $registration->set('REG_code', $registration_processor->generate_reg_code($registration));
             $registration->save();
             $transaction->_add_relation_to($registration, 'Registration');
         }
     }
 }
开发者ID:adrianjonmiller,项目名称:hearts-being-healed,代码行数:29,代码来源:EED_Multi_Event_Registration.module.php

示例4: generate_ONE_registration_from_line_item

 /**
  * generate_ONE_registration_from_line_item
  *
  * Although a ticket line item may have a quantity greater than 1,
  * this method will ONLY CREATE ONE REGISTRATION !!!
  * Regardless of the ticket line item quantity.
  * This means that any code calling this method is responsible for ensuring
  * that the final registration count matches the ticket line item quantity.
  * This was done to make it easier to match the number of registrations
  * to the number of tickets in the cart, when the cart has been edited
  * after SPCO has already been initialized. So if an additional ticket was added to the cart, you can simply pass
  * the line item to this method to add a second ticket, and in this case, you would not want to add 2 tickets.
  *
  * @param EE_Line_Item $line_item
  * @param \EE_Transaction $transaction
  * @param int $att_nmbr
  * @param int $total_ticket_count
  * @return \EE_Registration | null
  * @throws \EE_Error
  */
 public function generate_ONE_registration_from_line_item(EE_Line_Item $line_item, EE_Transaction $transaction, $att_nmbr = 1, $total_ticket_count = 1)
 {
     // grab the related ticket object for this line_item
     $ticket = $line_item->ticket();
     if (!$ticket instanceof EE_Ticket) {
         EE_Error::add_error(sprintf(__("Line item %s did not contain a valid ticket", "event_espresso"), $line_item->ID()), __FILE__, __FUNCTION__, __LINE__);
         return null;
     }
     $first_datetime = $ticket->get_first_related('Datetime');
     if (!$first_datetime instanceof EE_Datetime) {
         EE_Error::add_error(sprintf(__("The ticket (%s) is not associated with any valid datetimes.", "event_espresso"), $ticket->name()), __FILE__, __FUNCTION__, __LINE__);
         return null;
     }
     $event = $first_datetime->get_first_related('Event');
     if (!$event instanceof EE_Event) {
         EE_Error::add_error(sprintf(__("The ticket (%s) is not associated with a valid event.", "event_espresso"), $ticket->name()), __FILE__, __FUNCTION__, __LINE__);
         return null;
     }
     $reg_url_link = $this->generate_reg_url_link($att_nmbr, $line_item);
     // now create a new registration for the ticket
     $registration = EE_Registration::new_instance(array('EVT_ID' => $event->ID(), 'TXN_ID' => $transaction->ID(), 'TKT_ID' => $ticket->ID(), 'STS_ID' => EEM_Registration::status_id_incomplete, 'REG_date' => $transaction->datetime(), 'REG_final_price' => $ticket->get_ticket_total_with_taxes(), 'REG_session' => EE_Registry::instance()->SSN->id(), 'REG_count' => $att_nmbr, 'REG_group_size' => $total_ticket_count, 'REG_url_link' => $reg_url_link));
     $registration->set_reg_code($this->generate_reg_code($registration));
     $registration->save();
     $registration->_add_relation_to($event, 'Event', array(), $event->ID());
     $registration->_add_relation_to($line_item->ticket(), 'Ticket', array(), $line_item->ticket()->ID());
     $transaction->_add_relation_to($registration, 'Registration');
     return $registration;
 }
开发者ID:robert-osborne,项目名称:event-espresso-core-1,代码行数:48,代码来源:EE_Registration_Processor.class.php

示例5: _maybe_chained

 /**
  * This handles connecting a transaction to related items when the chained flag is true.
  *
  * @since 4.3.0
  *
  * @param EE_Transaction $transaction
  * @param array $args incoming arguments from caller for specifying overrides.
  *
  * @return EE_Transaction
  */
 private function _maybe_chained(EE_Transaction $transaction, $args)
 {
     if ($this->_chained) {
         if (empty($this->_status)) {
             $this->_set_repeated_relation($args, $transaction->ID());
         }
         //YES we DO want to set brand new relation objects because multiple transactions do not share the same related objects (for the purpose of tests at least)
         $this->_set_new_relations($args, $transaction->ID());
         //note relation to registration should already be set via the factory->registration_chained->create() method.
         //add relation to status
         $transaction->_add_relation_to($this->_status, 'Status');
         $transaction->save();
         return $transaction;
     }
     return $transaction;
 }
开发者ID:DavidSteinbauer,项目名称:event-espresso-core,代码行数:26,代码来源:EE_UnitTest_Factory_For_Transaction.class.php


注:本文中的EE_Transaction::_add_relation_to方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。