Example #1
0
 /**
  * Sets attendee data on order posts
  *
  * @since 4.1
  *
  * @param OrderEventMessage $order_event Shopp order event
  */
 public function save_attendee_meta_to_order(OrderEventMessage $order_event)
 {
     $order = shopp_order($order_event->order);
     $order_items = $order->purchased;
     // Bail if the order is empty
     if (empty($order_items)) {
         return;
     }
     $product_ids = array();
     // gather product ids
     foreach ((array) $order_items as $item) {
         if (empty($item->product)) {
             continue;
         }
         $product_ids[] = $item->product;
     }
     $meta_object = Tribe__Tickets_Plus__Main::instance()->meta();
     // build the custom meta data that will be stored in the order meta
     if (!($order_meta = $meta_object->build_order_meta($product_ids))) {
         return;
     }
     // store the custom meta on the order
     shopp_set_meta($order->id, 'purchase', Tribe__Tickets_Plus__Meta::META_KEY, $order_meta);
     // clear out product custom meta data cookies
     foreach ($product_ids as $product_id) {
         $meta_object->clear_meta_cookie_data($product_id);
     }
 }
Example #2
0
 /**
  * Sets attendee data on order posts
  *
  * @since 4.1
  *
  * @param int $order_id EDD Order ID
  * @param array $post_data Data submitted via POST during checkout
  */
 public function save_attendee_meta_to_order($order_id, $post_data)
 {
     $order_items = edd_get_payment_meta_cart_details($order_id);
     // Bail if the order is empty
     if (empty($order_items)) {
         return;
     }
     $product_ids = array();
     // gather product ids
     foreach ((array) $order_items as $item) {
         if (empty($item['id'])) {
             continue;
         }
         $product_ids[] = $item['id'];
     }
     $meta_object = Tribe__Tickets_Plus__Main::instance()->meta();
     // build the custom meta data that will be stored in the order meta
     if (!($order_meta = $meta_object->build_order_meta($product_ids))) {
         return;
     }
     // store the custom meta on the order
     update_post_meta($order_id, Tribe__Tickets_Plus__Meta::META_KEY, $order_meta, true);
     // clear out product custom meta data cookies
     foreach ($product_ids as $product_id) {
         $meta_object->clear_meta_cookie_data($product_id);
     }
 }
Example #3
0
 /**
  * Sets attendee data on order posts
  *
  * @since 4.1
  *
  * @param ShoppPurchase $purchase ShoppPurchase object
  */
 public function save_attendee_meta_to_order($data)
 {
     $purchase_log = new WPSC_Purchase_Log($data['purchase_log_id']);
     $order_items = $purchase_log->get_cart_contents();
     // Bail if the order is empty
     if (empty($order_items)) {
         return;
     }
     $product_ids = array();
     // gather product ids
     foreach ((array) $order_items as $item) {
         if (empty($item->prodid)) {
             continue;
         }
         $product_ids[] = $item->prodid;
     }
     $meta_object = Tribe__Tickets_Plus__Main::instance()->meta();
     // build the custom meta data that will be stored in the order meta
     if (!($order_meta = $meta_object->build_order_meta($product_ids))) {
         return;
     }
     // store the custom meta on the order
     $result = wpsc_add_purchase_meta($purchase_log->get('id'), Tribe__Tickets_Plus__Meta::META_KEY, $order_meta, true);
     // clear out product custom meta data cookies
     foreach ($product_ids as $product_id) {
         $meta_object->clear_meta_cookie_data($product_id);
     }
 }
function event_tickets_plus_init()
{
    tribe_init_tickets_plus_autoloading();
    $langpath = trailingslashit(basename(dirname(__FILE__))) . 'lang/';
    load_plugin_textdomain('event-tickets-plus', false, $langpath);
    if (event_tickets_plus_is_incompatible_tickets_core_installed()) {
        add_action('admin_notices', 'event_tickets_plus_show_fail_message');
        return;
    }
    Tribe__Tickets_Plus__Main::instance();
}
Example #5
0
 /**
  * If the current event has tickets that support attendee meta data, hook into
  * the list to add the appropriate number of extra columns.
  *
  * @param int $event_id
  */
 public function setup_columns($event_id)
 {
     $this->meta_columns = Tribe__Tickets_Plus__Main::instance()->meta()->get_meta_fields_by_event($event_id);
     if (empty($this->meta_columns)) {
         return;
     }
     //Add Handler for Community Tickets to Prevent Notices in Exports
     if (!is_admin()) {
         $screen_base = 'tribe_events_page_tickets-attendees';
     } else {
         $screen = get_current_screen();
         $screen_base = $screen->base;
     }
     $filter_name = "manage_{$screen_base}_columns";
     add_filter($filter_name, array($this, 'add_columns'), 20);
     add_filter('tribe_events_tickets_attendees_table_column', array($this, 'populate_columns'), 10, 3);
 }
Example #6
0
    public function metabox($fieldset)
    {
        $templates = array();
        $meta = get_post_meta($fieldset->ID, self::META_KEY, true);
        $ticket_id = null;
        $fieldset_form = true;
        $meta_object = Tribe__Tickets_Plus__Main::instance()->meta();
        $active_meta = array();
        if ($meta) {
            foreach ($meta as $field) {
                $active_meta[] = $meta_object->generate_field(null, $field['type'], $field);
            }
        }
        ?>
		<table id="tribetickets" class="event-tickets-plus-fieldset-table">
			<?php 
        include Tribe__Tickets_Plus__Main::instance()->plugin_path . 'src/admin-views/meta.php';
        ?>
		</table>
		<?php 
        wp_enqueue_style('event-tickets-meta');
        wp_enqueue_script('event-tickets-meta-admin');
    }
Example #7
0
 /**
  * Renders the field settings in the dashboard
  *
  * @since 4.1
  *
  * @return string
  */
 public function render_admin_field()
 {
     $tickets_plus = Tribe__Tickets_Plus__Main::instance();
     $name = $tickets_plus->plugin_path . 'src/admin-views/meta-fields/' . sanitize_file_name($this->type) . '.php';
     $wrapper = $tickets_plus->plugin_path . 'src/admin-views/meta-fields/_field.php';
     if (!file_exists($name)) {
         return '';
     }
     $data = (array) $this;
     $ticket_specific_settings = $this->get_field_settings();
     $data = array_merge($data, (array) $ticket_specific_settings);
     $field_id = rand();
     $type = $this->type;
     $label = !empty($data['label']) ? $data['label'] : '';
     $required = !empty($data['required']) ? $data['required'] : '';
     $slug = !empty($data['slug']) ? $data['slug'] : sanitize_title($label);
     $extra = !empty($data['extra']) ? $data['extra'] : '';
     ob_start();
     if (!empty($this->field_type_name[$this->type])) {
         $type_name = $this->field_type_name[$this->type];
     } else {
         $type_name = ucwords($this->type);
     }
     include $wrapper;
     $field = ob_get_clean();
     ob_start();
     include $name;
     $response = str_replace('##FIELD_EXTRA_DATA##', ob_get_clean(), $field);
     return $response;
 }
Example #8
0
 public function attendees_list()
 {
     if (!self::$attendees_list) {
         self::$attendees_list = Tribe__Tickets_Plus__Attendees_List::hook();
     }
     return self::$attendees_list;
 }
Example #9
0
 /**
  * Object accessor method for QR codes
  *
  * @return Tribe__Tickets_Plus__QR
  */
 public function qr()
 {
     if (!self::$qr) {
         self::$qr = new Tribe__Tickets_Plus__QR();
     }
     return self::$qr;
 }
Example #10
0
function event_tickets_plus_init()
{
    event_tickets_plus_setup_textdomain();
    Tribe__Tickets_Plus__Main::instance();
}
Example #11
0
    ?>
	<div class="tribe-event-tickets-plus-meta" id="tribe-event-tickets-plus-meta-<?php 
    echo esc_attr($ticket->ID);
    ?>
" data-ticket-id="<?php 
    echo esc_attr($ticket->ID);
    ?>
">
		<a class="attendee-meta toggle show"><?php 
    esc_html_e('Toggle attendee info', 'event-tickets-plus');
    ?>
</a>
		<div class="attendee-meta-row">
			<?php 
    if (!$meta->meta_enabled($ticket->ID)) {
        $meta_fields = Tribe__Tickets_Plus__Main::instance()->meta()->get_meta_fields_by_ticket($attendee['product_id']);
        $meta_data = get_post_meta($attendee['attendee_id'], Tribe__Tickets_Plus__Meta::META_KEY, true);
        foreach ($meta_fields as $field) {
            if ('checkbox' === $field->type && isset($field->extra['options'])) {
                $values = array();
                foreach ($field->extra['options'] as $option) {
                    $key = $field->slug . '_' . sanitize_title($option);
                    if (isset($meta_data[$key])) {
                        $values[] = $meta_data[$key];
                    }
                }
                $value = implode(', ', $values);
            } elseif (isset($meta_data[$field->slug])) {
                $value = $meta_data[$field->slug];
            } else {
                continue;
Example #12
0
 /**
  * Outputs the meta fields for the ticket
  */
 public function front_end_meta_fields($post, $ticket)
 {
     include Tribe__Tickets_Plus__Main::instance()->plugin_path . 'src/views/meta.php';
 }
Example #13
0
<?php

/**
 * Renders meta fields in the ticket form
 *
 * @version 4.1
 *
 */
$meta = Tribe__Tickets_Plus__Main::instance()->meta();
if (!$meta->meta_enabled($ticket->ID)) {
    return;
}
$meta_fields = $meta->get_meta_fields_by_ticket($ticket->ID);
?>
<tr class="tribe-event-tickets-plus-meta" id="tribe-event-tickets-plus-meta-<?php 
echo esc_attr($ticket->ID);
?>
" data-ticket-id="<?php 
echo esc_attr($ticket->ID);
?>
">
	<td colspan="4">
		<p class="tribe-event-tickets-meta-required-message">
			<?php 
esc_html_e('Please fill in all required fields', 'event-tickets-plus');
?>
		</p>
		<div class="tribe-event-tickets-plus-meta-fields" id="tribe-event-tickets-plus-meta-fields-<?php 
echo esc_attr($ticket->ID);
?>
"></div>
Example #14
0
 /**
  * Renders the Orders page
  */
 public function orders_page_inside()
 {
     $this->orders_table->prepare_items();
     $event_id = isset($_GET['event_id']) ? intval($_GET['event_id']) : 0;
     $event = get_post($event_id);
     $tickets = Tribe__Tickets__Tickets::get_event_tickets($event_id);
     /**
      * Filters whether or not fees are being passed to the end user (purchaser)
      *
      * @var boolean $pass_fees Whether or not to pass fees to user
      * @var int $event_id Event post ID
      */
     Tribe__Tickets_Plus__Commerce__WooCommerce__Orders__Table::$pass_fees_to_user = apply_filters('tribe_tickets_pass_fees_to_user', true, $event_id);
     /**
      * Filters the fee percentage to apply to a ticket/order
      *
      * @var float $fee_percent Fee percentage
      */
     Tribe__Tickets_Plus__Commerce__WooCommerce__Orders__Table::$fee_percent = apply_filters('tribe_tickets_fee_percent', 0, $event_id);
     /**
      * Filters the flat fee to apply to a ticket/order
      *
      * @var float $fee_flat Flat fee
      */
     Tribe__Tickets_Plus__Commerce__WooCommerce__Orders__Table::$fee_flat = apply_filters('tribe_tickets_fee_flat', 0, $event_id);
     ob_start();
     $this->orders_table->display();
     $table = ob_get_clean();
     $organizer = get_user_by('id', $event->post_author);
     $event_revenue = Tribe__Tickets_Plus__Commerce__WooCommerce__Orders__Table::event_revenue($event_id);
     $event_sales = Tribe__Tickets_Plus__Commerce__WooCommerce__Orders__Table::event_sales($event_id);
     $event_fees = Tribe__Tickets_Plus__Commerce__WooCommerce__Orders__Table::event_fees($event_id);
     $tickets_sold = array();
     $total_sold = 0;
     $total_pending = 0;
     $total_profit = 0;
     $total_completed = 0;
     foreach ($tickets as $ticket) {
         if (empty($tickets_sold[$ticket->name])) {
             $tickets_sold[$ticket->name] = array('ticket' => $ticket, 'has_stock' => !$ticket->stock(), 'sku' => get_post_meta($ticket->ID, '_sku', true), 'sold' => 0, 'pending' => 0, 'completed' => 0);
         }
         $stock = $ticket->stock();
         $sold = $ticket->qty_sold();
         $cancelled = $ticket->qty_cancelled();
         $net_sold = $sold - $cancelled;
         if ($net_sold < 0) {
             $net_sold = 0;
         }
         $tickets_sold[$ticket->name]['sold'] += $net_sold;
         $tickets_sold[$ticket->name]['pending'] += absint($ticket->qty_pending());
         $tickets_sold[$ticket->name]['completed'] += absint($tickets_sold[$ticket->name]['sold']) - absint($tickets_sold[$ticket->name]['pending']);
         $total_sold += $net_sold;
         $total_pending += absint($ticket->qty_pending());
     }
     $total_completed += absint($total_sold) - absint($total_pending);
     include Tribe__Tickets_Plus__Main::instance()->plugin_path . 'src/admin-views/woocommerce-orders.php';
 }
Example #15
0
 /**
  * Builds the meta data structure for storage in orders
  *
  * @since 4.1
  *
  * @param array $product_ids Collection of Product IDs in an order
  *
  * @return array
  */
 public function build_order_meta($product_ids)
 {
     if (!$product_ids) {
         return array();
     }
     $meta_object = Tribe__Tickets_Plus__Main::instance()->meta();
     $meta = array();
     foreach ($product_ids as $product_id) {
         $data = $meta_object->get_meta_cookie_data($product_id);
         if (!$data) {
             continue;
         }
         foreach ($data as $id => $the_meta) {
             if (!isset($meta[$id])) {
                 $meta[$id] = array();
             }
             $meta[$id] = array_merge_recursive($meta[$id], $the_meta);
         }
     }
     if (empty($meta)) {
         return array();
     }
     return $meta;
 }
Example #16
0
    /**
     * Inject custom meta in to tickets
     *
     * @param array $item Attendee data
     */
    public function ticket_email_meta($item)
    {
        $meta_fields = Tribe__Tickets_Plus__Main::instance()->meta()->get_meta_fields_by_ticket($item['product_id']);
        $meta_data = get_post_meta($item['qr_ticket_id'], Tribe__Tickets_Plus__Meta::META_KEY, true);
        if (!$meta_fields || !$meta_data) {
            return;
        }
        ?>
		<table class="inner-wrapper" border="0" cellpadding="0" cellspacing="0" width="620" bgcolor="#f7f7f7" style="margin:0 auto !important; width:620px; padding:0;">
			<tr>
				<td valign="top" class="ticket-content" align="left" width="580" border="0" cellpadding="20" cellspacing="0" style="padding:20px; background:#f7f7f7;" colspan="2">
					<h6 style="color:#909090 !important; margin:0 0 4px 0; font-family: 'Helvetica Neue', Helvetica, sans-serif; text-transform:uppercase; font-size:13px; font-weight:700 !important;"><?php 
        esc_html_e('Attendee Information', 'event-tickets-plus');
        ?>
</h6>
				</td>
			</tr>
			<?php 
        foreach ($meta_fields as $field) {
            if ('checkbox' === $field->type && isset($field->extra['options'])) {
                $values = array();
                foreach ($field->extra['options'] as $option) {
                    $key = $field->slug . '_' . sanitize_title($option);
                    if (isset($meta_data[$key])) {
                        $values[] = $meta_data[$key];
                    }
                }
                $value = implode(', ', $values);
            } elseif (isset($meta_data[$field->slug])) {
                $value = $meta_data[$field->slug];
            } else {
                continue;
            }
            ?>
				<tr>
					<th valign="top" class="event-tickets-meta-label_<?php 
            echo esc_attr($field->slug);
            ?>
" align="left" border="0" cellpadding="20" cellspacing="0" style="padding:0 20px; background:#f7f7f7;min-width:100px;">
						<?php 
            echo esc_html($field->label);
            ?>
					</th>
					<td valign="top" class="event-tickets-meta-data_<?php 
            echo esc_attr($field->slug);
            ?>
" align="left" border="0" cellpadding="20" cellspacing="0" style="padding:0 20px; background:#f7f7f7;">
						<?php 
            echo esc_html($value);
            ?>
					</td>
				</tr>
				<?php 
        }
        ?>
		</table>
		<?php 
    }
Example #17
0
 /**
  * Includes the Attendees List HTML
  *
  * @param  int|WP_Post $event
  * @return void
  */
 public function render($event = null, $limit = 20)
 {
     $event = get_post($event);
     if (!$event instanceof WP_Post) {
         $event = get_post();
     }
     if ('tribe_events_single_event_after_the_meta' === current_filter() && self::is_hidden_on($event)) {
         return;
     }
     // using the Attendees as a variable here allows more template configuration if needed
     $attendees = Tribe__Tickets__Tickets::get_event_attendees($event->ID);
     $attendees_total = count($attendees);
     if (0 === $attendees_total) {
         return;
     }
     $attendees_list = $this->get_attendees($event->ID, $limit);
     include_once Tribe__Tickets_Plus__Main::instance()->get_template_hierarchy('attendees-list');
 }
Example #18
0
 /**
  * Filter template paths to add the ET+ paths
  *
  * @param  array $paths
  * @return array $paths
  */
 public function add_template_path($paths)
 {
     $paths['plus'] = Tribe__Tickets_Plus__Main::instance()->plugin_path;
     return $paths;
 }
Example #19
0
    }
}
?>

		<?php 
if ($is_there_any_product_to_sell) {
    $color = isset($edd_options['checkout_color']) ? $edd_options['checkout_color'] : 'gray';
    $color = $color == 'inherit' ? '' : $color;
    ?>
			<tr>
				<td colspan="4" class="eddtickets-add">
					<?php 
    if ($must_login) {
        ?>
						<?php 
        include Tribe__Tickets_Plus__Main::instance()->get_template_hierarchy('login-to-purchase');
        ?>
					<?php 
    } else {
        ?>
						<button type="submit" class="edd-submit button <?php 
        echo esc_attr($color);
        ?>
"><?php 
        esc_html_e('Add to cart', 'event-tickets-plus');
        ?>
</button>
					<?php 
    }
    ?>
				</td>
Example #20
0
 /**
  * Stock counter class singleton accessor method.
  *
  * @return Tribe__Tickets_Plus__Commerce__Stock_Counter|Tribe__Tickets_Plus__Commerce__Total_Provider_Interface
  */
 public function stock_counter()
 {
     if (empty($this->stock_counter)) {
         $commerce_loader = Tribe__Tickets_Plus__Main::instance()->commerce_loader();
         $this->stock_counter = new Tribe__Tickets_Plus__Commerce__Stock_Counter($commerce_loader);
     }
     return $this->stock_counter;
 }