function __construct($id = '', $output = 'OBJECT')
 {
     $this->id = $id;
     $this->output = $output;
     $this->details = get_post($this->id, $this->output);
     $tickets = new TC_Orders();
     $fields = $tickets->get_order_fields();
     foreach ($fields as $field) {
         if (!isset($this->details->{$field['field_name']})) {
             $this->details->{$field['field_name']} = get_post_meta($this->id, $field['field_name'], true);
         }
     }
 }
예제 #2
0
<form>
    <input type="hidden" name="hiddenField" />
</form>

<script type="text/javascript">
	jQuery( document ).ready( function( $ ) {
		var replaceWith = $( '<input name="temp" class="tc_temp_value" type="text" />' ),
			connectWith = $( 'input[name="hiddenField"]' );

		$( 'td.first_name, td.last_name, td.owner_email' ).inlineEdit( replaceWith, connectWith );
	} );
</script>

<?php 
$orders = new TC_Orders();
$page = $_GET['page'];
if (isset($_POST['add_new_order'])) {
    if (check_admin_referer('save_order')) {
        if (current_user_can('manage_options') || current_user_can('save_order_cap')) {
            $orders->add_new_order();
            $message = __('Order Data data has been saved successfully.', 'tc');
        } else {
            $message = __('You do not have required permissions for this action.', 'tc');
        }
    }
}
if (isset($_GET['action']) && $_GET['action'] == 'details') {
    $order = new TC_Order($_GET['ID']);
    $post_id = (int) $_GET['ID'];
}
function tc_show_extra_profile_fields_order_history($user)
{
    global $tc;
    ?>

	<h3><?php 
    _e('Ticket Order History', 'tc');
    ?>
<a name="tc_order_history"></a></h3>

	<table class="form-table">

		<tr>
			<th></th>
			<td>
				<?php 
    $user_orders = TC_Orders::get_user_orders($user->ID);
    if (count($user_orders) == 0) {
        _e('No Orders Found', 'tc');
    } else {
        ?>
					<table cellspacing="0" class="widefat shadow-table" cellpadding="10">
						<tr>
							<td><?php 
        _e('Order ID', 'tc');
        ?>
</td>
							<td><?php 
        _e('Status', 'tc');
        ?>
</td>
							<td><?php 
        _e('Date', 'tc');
        ?>
</td>
							<td><?php 
        _e('Total', 'tc');
        ?>
</td>
							<td><?php 
        _e('Details', 'tc');
        ?>
</td>
						</tr>
						<?php 
        $style = '';
        foreach ($user_orders as $user_order) {
            $style = ' class="alternate"' == $style ? '' : ' class="alternate"';
            $order = new TC_Order($user_order->ID);
            ?>
							<tr <?php 
            echo $style;
            ?>
> 
								<td>
									<?php 
            echo $order->details->post_title;
            ?>
								</td>
								<td>
									<?php 
            $post_status = $order->details->post_status;
            $init_post_status = $post_status;
            if ($post_status == 'order_fraud') {
                $color = "red";
            } else {
                if ($post_status == 'order_received') {
                    $color = "#ff6600";
                    //yellow
                } else {
                    if ($post_status == 'order_paid') {
                        $color = "green";
                    }
                }
            }
            if ($post_status == 'order_fraud') {
                $post_status = __('Held for Review', 'tc');
            }
            $post_status = ucwords(str_replace('_', ' ', $post_status));
            echo sprintf(__('%1$s %2$s %3$s', 'tc'), '<font color="' . apply_filters('tc_order_history_color', $color, $init_post_status) . '">', __(ucwords($post_status), 'tc'), '</font>');
            ?>
								</td>
								<td>
									<?php 
            echo tc_format_date($order->details->tc_order_date, true);
            ?>
								</td>
								<td>
									<?php 
            echo apply_filters('tc_cart_currency_and_format', $order->details->tc_payment_info['total']);
            ?>
								</td>
								<td>
									<?php 
            $order_status_url = admin_url('edit.php?post_type=tc_events&page=tc_orders&action=details&ID=' . $order->details->ID);
            ?>
									<a href="<?php 
            echo $order_status_url;
            ?>
"><?php 
            _e('Order Details', 'tc');
            ?>
</a>
								</td>
							</tr>
							<?php 
        }
        ?>
					</table>
					<?php 
    }
    ?>
			</td>
		</tr>

	</table>
	<?php 
}
function tc_get_order_event($field_name = '', $post_id = '')
{
    $order_status = get_post_status($post_id);
    $order_status = $order_status == 'trash' ? 'trash' : 'publish';
    $orders = new TC_Orders();
    $user_id = get_current_user_id();
    $order_id = get_the_title($post_id);
    $cart_contents = get_post_meta($post_id, 'tc_cart_contents', true);
    $cart_info = get_post_meta($post_id, 'tc_cart_info', true);
    $owner_data = isset($cart_info['owner_data']) ? $cart_info['owner_data'] : array();
    $tickets = count($cart_contents);
    $args = array('posts_per_page' => -1, 'orderby' => 'post_date', 'order' => 'ASC', 'post_type' => 'tc_tickets_instances', 'post_status' => array('trash', 'publish'), 'post_parent' => $post_id);
    $tickets = get_posts($args);
    $columns = $orders->get_owner_info_fields();
    $columns = apply_filters('tc_order_details_owner_columns', $columns);
    $style = '';
    ?>

	<table class="order-details widefat shadow-table">
		<tr>
			<?php 
    foreach ($columns as $column) {
        ?>
				<th><?php 
        echo $column['field_title'];
        ?>
</th>
				<?php 
    }
    ?>
		</tr>

		<?php 
    foreach ($tickets as $ticket) {
        $style = ' class="alternate"' == $style ? '' : ' class="alternate"';
        ?>
			<tr <?php 
        echo $style;
        ?>
>
				<?php 
        foreach ($columns as $column) {
            ?>
					<td class="<?php 
            echo esc_attr($column['field_name']);
            ?>
" data-id="<?php 
            echo $column['field_name'] == 'ID' ? $ticket->ID : '';
            ?>
">
						<?php 
            if ($column['field_type'] == 'function') {
                eval($column['function'] . '("' . $column['field_name'] . '", "' . (isset($column['field_id']) ? $column['field_id'] : '') . '", "' . $ticket->ID . '");');
            } else {
                if ($column['post_field_type'] == 'post_meta') {
                    $value = get_post_meta($ticket->ID, $column['field_name'], true);
                    if (empty($value)) {
                        echo '-';
                    } else {
                        echo $value;
                    }
                }
                if ($column['post_field_type'] == 'ID') {
                    echo $ticket->ID;
                }
            }
            ?>
					</td>
				<?php 
        }
        ?>
			</tr>
			<?php 
    }
    ?>
	</table>
	<?php 
    if (count($tickets) == 0 && count($cart_contents) > 0) {
        ?>
		<div class="tc_order_tickets_warning">
			<?php 
        _e('We can\'t find any ticket associated with this order. It seems that attendee info / ticket is deleted.', 'tc');
        ?>
		</div>
		<?php 
    }
}
function tc_get_order_event($field_name = '', $post_id = '')
{
    $order_status = get_post_status($post_id);
    $order_status = $order_status == 'trash' ? 'trash' : 'publish';
    $orders = new TC_Orders();
    $user_id = get_current_user_id();
    $order_id = get_the_title($post_id);
    $cart_contents = get_post_meta($post_id, 'tc_cart_contents', true);
    $cart_info = get_post_meta($post_id, 'tc_cart_info', true);
    $owner_data = $cart_info['owner_data'];
    $tickets = count($cart_contents);
    if (isset($_POST['recreate_tickets'])) {
        //recreating tickets
        //Save Ticket Owner(s) data
        //$owner_data		 = $_SESSION[ 'cart_info' ][ 'owner_data' ];
        $owner_records = array();
        $different_ticket_types = array_keys($owner_data['ticket_type_id_post_meta']);
        $n = 0;
        $i = 1;
        foreach ($different_ticket_types as $different_ticket_type) {
            $i = $i + 10;
            foreach ($owner_data as $field_name => $field_values) {
                $inner_count = count($field_values[$different_ticket_type]);
                foreach ($field_values[$different_ticket_type] as $field_value) {
                    $owner_records[((int) $n + (int) $inner_count) * (int) $i][$field_name] = $field_value;
                    $inner_count = $inner_count + 1;
                }
            }
            $n = $n++;
        }
        $owner_record_num = 1;
        foreach ($owner_records as $owner_record) {
            foreach ($owner_record as $owner_field_name => $owner_field_value) {
                if (preg_match('/_post_title/', $owner_field_name)) {
                    $title = $owner_field_value;
                }
                if (preg_match('/_post_excerpt/', $owner_field_name)) {
                    $excerpt = $owner_field_value;
                }
                if (preg_match('/_post_content/', $owner_field_name)) {
                    $content = $owner_field_value;
                }
                if (preg_match('/_post_meta/', $owner_field_name)) {
                    $metas[str_replace('_post_meta', '', $owner_field_name)] = $owner_field_value;
                }
            }
            $metas['ticket_code'] = apply_filters('tc_ticket_code', $order_id . '-' . $owner_record_num);
            $arg = array('post_author' => isset($user_id) ? $user_id : '', 'post_parent' => $post_id, 'post_excerpt' => isset($excerpt) ? $excerpt : '', 'post_content' => isset($content) ? $content : '', 'post_status' => $order_status, 'post_title' => isset($title) ? $title : '', 'post_type' => 'tc_tickets_instances');
            $owner_record_id = @wp_insert_post($arg, true);
            foreach ($metas as $meta_name => $mata_value) {
                update_post_meta($owner_record_id, $meta_name, $mata_value);
            }
            $ticket_type_id = get_post_meta($owner_record_id, 'ticket_type_id', true);
            $ticket_type = new TC_Ticket($ticket_type_id);
            $event_id = $ticket_type->get_ticket_event();
            update_post_meta($owner_record_id, 'event_id', $event_id);
            $owner_record_num++;
        }
    }
    //END recreating tickets
    $args = array('posts_per_page' => -1, 'orderby' => 'post_date', 'order' => 'ASC', 'post_type' => 'tc_tickets_instances', 'post_status' => array('trash', 'publish'), 'post_parent' => $post_id);
    $tickets = get_posts($args);
    $columns = $orders->get_owner_info_fields();
    $columns = apply_filters('tc_order_details_owner_columns', $columns);
    $style = '';
    ?>
	<table class="order-details widefat shadow-table">
		<tr>
			<?php 
    foreach ($columns as $column) {
        ?>
				<th><?php 
        echo $column['field_title'];
        ?>
</th>
				<?php 
    }
    ?>
		</tr>

		<?php 
    foreach ($tickets as $ticket) {
        $style = ' class="alternate"' == $style ? '' : ' class="alternate"';
        ?>
			<tr <?php 
        echo $style;
        ?>
>
				<?php 
        foreach ($columns as $column) {
            ?>
					<td class="<?php 
            echo esc_attr($column['field_name']);
            ?>
" data-id="<?php 
            echo $column['field_name'] == 'ID' ? $ticket->ID : '';
            ?>
">
						<?php 
            if ($column['field_type'] == 'function') {
                eval($column['function'] . '("' . $column['field_name'] . '", "' . (isset($column['field_id']) ? $column['field_id'] : '') . '", "' . $ticket->ID . '");');
            } else {
                if ($column['post_field_type'] == 'post_meta') {
                    $value = get_post_meta($ticket->ID, $column['field_name'], true);
                    if (empty($value)) {
                        echo '-';
                    } else {
                        echo $value;
                    }
                }
                if ($column['post_field_type'] == 'ID') {
                    echo $ticket->ID;
                }
            }
            ?>
					</td>
				<?php 
        }
        ?>
			</tr>
			<?php 
    }
    ?>
	</table>
	<?php 
    if (count($tickets) == 0 && count($cart_contents) > 0) {
        ?>
		<div class="status_red tc_order_tickets_warning">
			<?php 
        _e('There are not any tickets. Would you like to try to recreate them? ', 'tc');
        ?>
			<form name="tc_recreate_tickets" method="POST">
				<input type="submit" name="recreate_tickets" value="<?php 
        echo esc_attr(__('Recrete Tickets', 'tc'));
        ?>
" />
			</form>
		</div>
		<?php 
    }
}
<?php

if (!is_user_logged_in()) {
    printf(__('Please %s to see your order history.', 'tc'), '<a href="' . wp_login_url() . '">' . __('log in', 'tc') . '</a>');
} else {
    $user_orders = TC_Orders::get_user_orders();
    ?>
	<div class="tc-container">
		<?php 
    if (count($user_orders) == 0) {
        _e('No Orders Found', 'tc');
    } else {
        ?>
			<table cellspacing="0" class="tickera_table" cellpadding="10">
				<tr>
					<th><?php 
        _e('Status', 'tc');
        ?>
</th>
					<th><?php 
        _e('Date', 'tc');
        ?>
</th>
					<th><?php 
        _e('Total', 'tc');
        ?>
</th>
					<th><?php 
        _e('Details', 'tc');
        ?>
</th>