Ejemplo n.º 1
0
 /**
  * Filters the CSV post types to add RSVP tickets
  *
  * @param array $post_types Array of post type objects
  *
  * @return array
  */
 public function filter_csv_post_types(array $post_types)
 {
     $post_type = get_post_type_object(Tribe__Tickets__RSVP::get_instance()->ticket_object);
     $post_type->labels->name = _x('RSVPs', 'post type label', 'event-tickets');
     $post_types[] = $post_type;
     return $post_types;
 }
Ejemplo n.º 2
0
 /**
  * @param array $record
  *
  * @return int|bool Either the new RSVP ticket post ID or `false` on failure.
  */
 public function create_post(array $record)
 {
     $event = $this->get_event_from($record);
     $data = $this->get_ticket_data_from($record);
     $ticket_id = $this->rsvp_tickets->ticket_add($event->ID, $data);
     $ticket_name = $this->get_value_by_key($record, 'ticket_name');
     $cache_key = $ticket_name . '-' . $event->ID;
     self::$ticket_name_cache[$cache_key] = true;
     return $ticket_id;
 }
 /**
  * @param array $record
  *
  * @return int|bool Either the new RSVP ticket post ID or `false` on failure.
  */
 public function create_post(array $record)
 {
     $event = $this->get_event_from($record);
     $data = $this->get_ticket_data_from($record);
     $ticket_id = $this->rsvp_tickets->ticket_add($event->ID, $data);
     $ticket_name = $this->get_value_by_key($record, 'ticket_name');
     $cache_key = $ticket_name . '-' . $event->ID;
     self::$ticket_name_cache[$cache_key] = true;
     if ($this->is_aggregator && !empty($this->aggregator_record)) {
         $this->aggregator_record->meta['activity']->add('rsvp_tickets', 'created', $ticket_id);
     }
     return $ticket_id;
 }
 /**
  * Calculate total RSVP attendance for the current event.
  */
 protected function calculate_totals()
 {
     foreach (Tribe__Tickets__RSVP::get_instance()->get_attendees_array($this->event_id) as $attendee) {
         switch ($attendee['order_status']) {
             case 'yes':
                 $this->total_going++;
                 break;
             case 'no':
                 $this->total_not_going++;
                 break;
         }
     }
     $this->total_rsvps = $this->total_going + $this->total_not_going;
 }
Ejemplo n.º 5
0
 /**
  * When a ticket does not have a stock value, make sure the object returns expected value druing the life of
  * the in-stock values
  */
 public function test_ticket_without_stock()
 {
     $start = strtotime(date('Y-m-d H:00:00'));
     $end = strtotime(date('Y-m-d H:00:00', strtotime('+5 days')));
     $data = ['ticket_provider' => 'Tribe__Tickets__RSVP', 'ticket_name' => __METHOD__, 'ticket_description' => __CLASS__ . '::' . __METHOD__, 'ticket_start_date' => date('Y-m-d', $start), 'ticket_start_hour' => date('H', $start), 'ticket_start_minute' => date('i', $start), 'ticket_end_date' => date('Y-m-d', $end), 'ticket_end_hour' => date('H', $end), 'ticket_end_minute' => date('i', $end), 'ticket_rsvp_stock' => ''];
     $rsvp = Tribe__Tickets__RSVP::get_instance();
     $rsvp->ticket_add(1, $data);
     $tickets = $rsvp->get_event_tickets(1);
     $this->assertArrayHasKey(0, $tickets, 'RSVP ticket has been created');
     $ticket = $tickets[0];
     $this->assertFalse($ticket->managing_stock(), 'RSVP ticket is not managing stock');
     $this->assertEquals('', $ticket->original_stock(), 'RSVP ticket is not managing stock, so original stock should be blank');
     $this->assertEquals(0, $ticket->remaining(), 'RSVP ticket has the appropriate remaining stock amount');
     $this->assertTrue($ticket->is_in_stock(), 'RSVP ticket that is not managing stock should be report that it is in stock');
     // sell one ticket
     update_post_meta($ticket->ID, 'total_sales', 1);
     $tickets = $rsvp->get_event_tickets(1);
     $ticket = $tickets[0];
     $this->assertEquals('', $ticket->original_stock(), 'RSVP ticket has the appropriate stock amount after selling 1 ticket');
     $this->assertEquals(0, $ticket->remaining(), 'RSVP ticket has the appropriate remaining stock amount after selling 1 ticket');
     $this->assertTrue($ticket->is_in_stock(), 'RSVP ticket is in stock after selling 1 ticket');
     // sell 100000 tickets
     update_post_meta($ticket->ID, 'total_sales', 100000);
     $tickets = $rsvp->get_event_tickets(1);
     $ticket = $tickets[0];
     $this->assertEquals('', $ticket->original_stock(), 'RSVP ticket has the appropriate stock amount after selling 100000 tickets');
     $this->assertEquals(0, $ticket->remaining(), 'RSVP ticket has the appropriate remaining stock amount after selling 100000 tickets');
     $this->assertTrue($ticket->is_in_stock(), 'RSVP ticket is in stock after selling 100000 tickets');
     // switch to stock-tracking tickets
     $data['ticket_rsvp_stock'] = 100;
     $rsvp->save_ticket(1, $ticket, $data);
     $tickets = $rsvp->get_event_tickets(1);
     $ticket = $tickets[0];
     $this->assertTrue($ticket->managing_stock(), 'RSVP ticket is now managing stock');
     $this->assertEquals(100100, $ticket->original_stock(), 'RSVP ticket is now managing stock, so original stock should be blank');
     $this->assertEquals(100, $ticket->remaining(), 'RSVP ticket has the appropriate remaining stock amount');
     $this->assertTrue($ticket->is_in_stock(), 'RSVP ticket that is now managing stock should be report that it is in stock');
 }
Ejemplo n.º 6
0
 /**
  * rsvp ticket object accessor
  */
 public function rsvp()
 {
     static $rsvp;
     if (!$rsvp) {
         $rsvp = Tribe__Tickets__RSVP::get_instance();
     }
     return $rsvp;
 }
Ejemplo n.º 7
0
 /**
  * rsvp ticket object accessor
  */
 public function rsvp()
 {
     return Tribe__Tickets__RSVP::get_instance();
 }
Ejemplo n.º 8
0
 /**
  * Get (and instantiate, if necessary) the instance of the class
  *
  * @static
  * @return Tribe__Tickets__RSVP
  */
 public static function get_instance()
 {
     if (!self::$instance) {
         self::$instance = new self();
     }
     return self::$instance;
 }
Ejemplo n.º 9
0
 /**
  * Get (and instantiate, if necessary) the instance of the class
  *
  * @static
  * @return Tribe__Tickets__RSVP
  */
 public static function get_instance()
 {
     if (!is_a(self::$instance, __CLASS__)) {
         self::$instance = new self();
     }
     return self::$instance;
 }
Ejemplo n.º 10
0
<?php

$is_there_any_product = false;
$is_there_any_product_to_sell = false;
ob_start();
?>
<form action="" class="cart" method="post" enctype='multipart/form-data'>
	<h2 class="tribe-events-tickets-title"><?php 
esc_html_e('RSVP', 'event-tickets');
?>
</h2>
	<?php 
$messages = Tribe__Tickets__RSVP::get_instance()->get_messages();
if ($messages) {
    ?>
		<div class="tribe-rsvp-messages">
			<?php 
    foreach ($messages as $message) {
        ?>
				<div class="tribe-rsvp-message tribe-rsvp-message-<?php 
        echo esc_attr($message->type);
        ?>
">
					<?php 
        echo esc_html($message->message);
        ?>
				</div>
				<?php 
    }
    //end foreach
    ?>