コード例 #1
0
ファイル: eventon-tickets.php プロジェクト: sabdev1/ljcdevsab
 public function send_ticket_email($order_id)
 {
     global $woocommerce;
     //$order_id = 402;
     $order_meta = get_post_custom($order_id);
     // check if order contain event ticket data
     if (!empty($order_meta['_order_type'])) {
         $evotx_opt = $this->evotx_opt;
         $order = new WC_Order($order_id);
         $tickets = $order->get_items();
         // CHECK if any of the order items have ticket in it
         $_has_ticket = false;
         foreach ($tickets as $item) {
             $eid = get_post_meta($item['product_id'], '_eventid', true);
             if (!empty($eid)) {
                 $_has_ticket = true;
                 break;
             }
         }
         // STOP if there arent any tickets in the order
         if (!$_has_ticket) {
             return;
         }
         // include HTML email filter
         add_filter('wp_mail_content_type', create_function('', 'return "text/html";'));
         if ($order_meta['_customer_user'][0] == 0) {
             // no account created
             $__to_email = $order_meta['_billing_email'][0];
             $__customer_name = $order_meta['_billing_first_name'][0] . ' ' . $order_meta['_billing_last_name'][0];
         } else {
             $usermeta = get_user_meta($order_meta['_customer_user'][0]);
             $__to_email = $usermeta['billing_email'][0];
             $__customer_name = $usermeta['first_name'][0] . ' ' . $usermeta['last_name'][0];
         }
         // arguments for email body
         $email_body_arguments = array('orderid' => $order_id, 'tickets' => $tickets, 'customer' => $__customer_name, 'email' => 'yes');
         $__from_email = !empty($evotx_opt['evotx_notfiemailfrom']) ? htmlspecialchars_decode($evotx_opt['evotx_notfiemailfrom']) : get_bloginfo('admin_email');
         $__from_email_name = !empty($evotx_opt['evotx_notfiemailfromN']) ? $evotx_opt['evotx_notfiemailfromN'] : get_bloginfo('name');
         $from_email = !empty($__from_email_name) ? $__from_email_name . ' <' . $__from_email . '>' : $__from_email;
         $subject = '[#' . $order_id . '] ' . (!empty($evotx_opt['evotx_notfiesubjest']) ? $evotx_opt['evotx_notfiesubjest'] : __('Event Ticket', 'eventon'));
         $headers = 'From: ' . $from_email;
         // get the email body
         $tix = new evotx_ticket();
         $body = $tix->get_ticket_email_body($email_body_arguments);
         $send_wp_mail = wp_mail($__to_email, $subject, $body, $headers);
         //echo $__to_email.' '.$headers;
         return $send_wp_mail;
     }
 }
コード例 #2
0
function evotx_metabox_002()
{
    global $post, $evotx;
    $ticketItem_meta = get_post_meta($post->ID);
    $ticket_item = new evotx_TicketItem($post->ID, $ticketItem_meta);
    $tix = new evotx_ticket();
    // Debug email templates
    $show_debug_email = false;
    if ($show_debug_email) {
        $order_id = $ticketItem_meta['_orderid'][0];
        $order = new WC_Order($order_id);
        $tickets = $order->get_items();
        $email_body_arguments = array('orderid' => $order_id, 'tickets' => $tickets, 'customer' => 'Ashan Jay', 'email' => 'yes');
        $tt = $tix->get_ticket_email_body($email_body_arguments);
        print_r($tt);
    }
    // get event times
    $event_id = !empty($ticketItem_meta['_eventid']) ? $ticketItem_meta['_eventid'][0] : '';
    $event_time = $ticket_item->get_event_time($event_id);
    // get corrected event ticket ids
    if (empty($ticketItem_meta['ticket_ids'][0])) {
        $tix->correct_tix_ids($ticketItem_meta, $post->ID);
    }
    ?>
	
		<div class='eventon_mb' style='margin:-6px -12px -12px'>
		<div style='background-color:#ECECEC; padding:15px;'>
			<div style='background-color:#fff; border-radius:8px;'>
			<table width='100%' class='evo_metatable' cellspacing="" style='vertical-align:top' valign='top'>
				<tr><td><?php 
    _e('Woocommerce Order ID', 'eventon');
    ?>
 #: </td><td><?php 
    echo '<a class="button" href="' . get_edit_post_link($ticketItem_meta['_orderid'][0]) . '">' . $ticketItem_meta['_orderid'][0] . '</a>';
    ?>
</td></tr>				
				<tr><td><?php 
    _e('Ticket Type', 'eventon');
    ?>
: </td><td><?php 
    echo !$ticketItem_meta['type'] ? $ticketItem_meta['type'][0] : '--';
    ?>
</td></tr>

				<?php 
    $ticket_holder = !empty($ticketItem_meta['_customerid'][0]) && $ticketItem_meta['_customerid'][0] != '0' ? '<a href="' . get_edit_user_link($ticketItem_meta['_customerid'][0]) . '">' . $ticketItem_meta['name'][0] . '</a>' : $ticketItem_meta['name'][0];
    ?>
				<tr><td><?php 
    _e('Ticket Holder', 'eventon');
    ?>
: </td><td><?php 
    echo $ticket_holder;
    ?>
</td></tr>
				<tr><td><?php 
    _e('Email Address', 'eventon');
    ?>
: </td><td><?php 
    echo $ticketItem_meta['email'][0];
    ?>
</td></tr>
				<tr><td><?php 
    _e('Quantity', 'eventon');
    ?>
: </td><td><?php 
    echo $ticketItem_meta['qty'][0];
    ?>
</td></tr>
				<tr><td><?php 
    _e('Cost for ticket(s)', 'eventon');
    ?>
: </td><td><?php 
    echo get_woocommerce_currency_symbol() . $ticketItem_meta['cost'][0];
    ?>
</td></tr>
				<tr><td><?php 
    _e('Event', 'eventon');
    ?>
: </td>
				<td><?php 
    echo '<a href="' . get_edit_post_link($event_id) . '">' . get_the_title($ticketItem_meta['_eventid'][0]) . '</a>';
    ?>

					<?php 
    // if this is a repeat event show repeat information
    $event_meta = get_post_meta($event_id);
    if (!empty($event_meta['evcal_repeat']) && $event_meta['evcal_repeat'][0] == 'yes') {
        echo "<p>This is a repeating event.</p>";
    }
    ?>
				</td></tr>
				<?php 
    // get translated checkin status
    $st_count = $ticket_item->checked_count();
    $status = $ticket_item->get_checkin_status('checked');
    $__count = ': ' . (!empty($st_count['checked']) ? $st_count['checked'] : '0') . ' out of ' . $ticketItem_meta['qty'][0];
    ?>
				<tr><td><?php 
    _e('Ticket Status', 'eventon');
    ?>
: </td><td><?php 
    echo $status . $__count;
    ?>
</td></tr>
				<tr><td><?php 
    _e('Ticket Time', 'eventon');
    ?>
: </td><td><?php 
    echo $event_time;
    ?>
</td></tr>
				<tr><td ><?php 
    _e('Ticket(s)', 'eventon');
    ?>
 #: </td><td>
					<?php 
    // get ticket IDs for this ticket item
    $ticketids = $ticket_item->ticket_ids();
    ?>
					<table id='evotx_ticketItem_tickets'>
						<?php 
    if (is_array($ticketids)) {
        foreach ($ticketids as $ff => $vv) {
            ?>
								<tr><td><?php 
            echo apply_filters('evotx_tixPost_tixid', $ff);
            ?>
<br/><span class='tix_status <?php 
            echo $vv;
            ?>
' data-tiid='<?php 
            echo $post->ID;
            ?>
' data-tid='<?php 
            echo $ff;
            ?>
' data-status='<?php 
            echo $vv;
            ?>
'><?php 
            echo $ticket_item->get_checkin_status($vv);
            ?>
</span></td></tr>
						<?php 
        }
    } else {
        echo "<tr><td>{$ticketids}</td></tr>";
    }
    ?>
					</table>

				</td></tr>
				<?php 
    do_action('eventontx_tix_post_table', $post->ID, $ticketItem_meta);
    ?>
			</table>
			</div>
		</div>
		</div>
		<?php 
}