本文整理汇总了PHP中EE_Transaction::get_first_related方法的典型用法代码示例。如果您正苦于以下问题:PHP EE_Transaction::get_first_related方法的具体用法?PHP EE_Transaction::get_first_related怎么用?PHP EE_Transaction::get_first_related使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EE_Transaction
的用法示例。
在下文中一共展示了EE_Transaction::get_first_related方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
/**
* generates HTML for the Transaction main meta box
* @access private
* @return void
*/
function _txn_details_meta_box()
{
global $wpdb;
$this->_set_transaction_object();
//get line items from transaction
$this->_template_args['line_items'] = $this->_transaction->get_many_related('Line_Item', array(array('LIN_type' => 'line-item')));
$this->_template_args['REG_code'] = $this->_transaction->get_first_related('Registration')->get('REG_code');
// process taxes
if ($taxes = $this->_transaction->get_many_related('Line_Item', array(array('LIN_type' => EEM_Line_Item::type_tax)))) {
$this->_template_args['taxes'] = $taxes;
} else {
$this->_template_args['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
if (!($this->_template_args['payments'] = $this->_transaction->get_many_related('Payment'))) {
$this->_template_args['payments'] = FALSE;
}
$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']['invoice_number']['class'] = 'regular-text';
}
$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']['registration_session']['class'] = 'regular-text';
$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']['ip_address']['class'] = 'regular-text';
$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');
$this->_template_args['txn_details']['user_agent']['class'] = 'large-text';
$this->_get_payment_methods();
$this->_get_active_gateways();
$this->_get_payment_status_array();
$this->_get_reg_status_selection();
//setsup 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);
}
示例2: txn_details_meta_box
/**
* 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 items from transaction
$this->_template_args['line_items'] = $this->_transaction->get_many_related('Line_Item', array(array('LIN_type' => '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);
}
示例3: maybe_registration
/**
* Trigger for Registration messages
* Note that what registration message type is sent depends on what the reg status is for the registrations on the incoming transaction.
* @param EE_Transaction $transaction
* @return void
*/
public function maybe_registration(EE_Transaction $transaction, $reg_msg, $from_admin)
{
$this->_load_controller();
//for now we're ONLY doing this from frontend UNLESS we have the toggle to send.
if ($from_admin) {
$messages_toggle = !empty($_REQUEST['txn_reg_status_change']['send_notifications']) && $_REQUEST['txn_reg_status_change']['send_notifications'] ? TRUE : FALSE;
if (!$messages_toggle) {
return;
}
//no messages sent please.
}
//next let's only send out notifications if a registration was created OR if the registration status was updated to approved
if (!$reg_msg['new_reg'] && !$reg_msg['to_approved']) {
return;
}
$data = array($transaction, NULL);
//let's get the first related reg on the transaction since we can use its status to determine what message type gets sent.
$registration = $transaction->get_first_related('Registration');
$reg_status = $registration->status_ID();
//send the message type matching the status if that message type is active.
//first an array to match for class name
$status_match_array = $this->_get_reg_status_array();
$active_mts = $this->_EEMSG->get_active_message_types();
if (in_array($status_match_array[$reg_status], $active_mts)) {
$this->_EEMSG->send_message($status_match_array[$reg_status], $data);
}
return;
//if we get here then there is no active message type for this status.
}
示例4: _get_return_page_url
/**
* get thank you page url
*
* @access public
* @param EE_Transaction $transaction
* @return void
*/
private function _get_return_page_url(EE_Transaction $transaction)
{
do_action('AHEE_log', __FILE__, __FUNCTION__, '');
//get thank you page url
$return_page_url = rtrim(get_permalink(EE_Registry::instance()->CFG->core->thank_you_page_id), '/');
$registration = $transaction->get_first_related('Registration');
//$reg = $transaction->primary_registration();
// printr( $reg, '$reg <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
// die();
if ($registration instanceof EE_Registration) {
$return_page_url = add_query_arg(array('e_reg_url_link' => $registration->reg_url_link()), $return_page_url);
} else {
throw new EE_Error(sprintf(__('Could not find a valid primary registration for this transaction', "event_espresso")));
}
return $return_page_url;
}