1
|
|
|
<?php |
2
|
|
|
namespace EventEspresso\modules\ticket_selector; |
3
|
|
|
|
4
|
|
|
defined('ABSPATH') || exit; |
5
|
|
|
|
6
|
|
|
|
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* Class TicketSelectorStandard |
10
|
|
|
* regular ticket selector that displays one row for each ticket |
11
|
|
|
* with a dropdown for selecting the desired ticket quantity |
12
|
|
|
* |
13
|
|
|
* @package Event Espresso |
14
|
|
|
* @author Brent Christensen |
15
|
|
|
* @since 4.9.18 |
16
|
|
|
*/ |
17
|
|
|
class TicketSelectorStandard extends TicketSelector |
18
|
|
|
{ |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @var string $date_format |
22
|
|
|
*/ |
23
|
|
|
protected $date_format; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @var string $time_format |
27
|
|
|
*/ |
28
|
|
|
protected $time_format; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @var \EE_Ticket_Selector_Config $ticket_selector_config |
32
|
|
|
*/ |
33
|
|
|
protected $ticket_selector_config; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @var \EE_Tax_Config $tax_config |
37
|
|
|
*/ |
38
|
|
|
protected $tax_config; |
39
|
|
|
|
40
|
|
|
|
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* TicketSelectorSimple constructor. |
44
|
|
|
* |
45
|
|
|
* @param \EE_Event $event |
46
|
|
|
* @param \EE_Ticket[] $tickets |
47
|
|
|
* @param int $max_attendees |
48
|
|
|
* @param array $template_args |
49
|
|
|
* @param string $date_format |
50
|
|
|
* @param string $time_format |
51
|
|
|
* @param \EE_Ticket_Selector_Config $ticket_selector_config |
52
|
|
|
* @param \EE_Tax_Config $tax_config |
53
|
|
|
*/ |
54
|
|
|
public function __construct( |
55
|
|
|
\EE_Event $event, |
56
|
|
|
array $tickets, |
57
|
|
|
$max_attendees, |
58
|
|
|
array $template_args, |
59
|
|
|
$date_format = 'Y-m-d', |
60
|
|
|
$time_format = 'g:i a', |
61
|
|
|
\EE_Ticket_Selector_Config $ticket_selector_config = null, |
|
|
|
|
62
|
|
|
\EE_Tax_Config $tax_config = null |
|
|
|
|
63
|
|
|
) { |
64
|
|
|
$this->date_format = $date_format; |
65
|
|
|
$this->time_format = $time_format; |
66
|
|
|
// get EE_Ticket_Selector_Config and TicketDetails |
67
|
|
|
$this->ticket_selector_config = isset (\EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector) |
68
|
|
|
? \EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector |
69
|
|
|
: new \EE_Ticket_Selector_Config(); |
70
|
|
|
// $template_settings->setDatetimeSelectorThreshold(2); |
71
|
|
|
// \EEH_Debug_Tools::printr($template_settings->getShowDatetimeSelector(), 'getShowDatetimeSelector', __FILE__, __LINE__); |
72
|
|
|
// \EEH_Debug_Tools::printr($template_settings->getDatetimeSelectorThreshold(), 'getDatetimeSelectorThreshold', __FILE__, __LINE__); |
73
|
|
|
$this->tax_config = isset (\EE_Registry::instance()->CFG->tax_settings) |
74
|
|
|
? \EE_Registry::instance()->CFG->tax_settings |
75
|
|
|
: new \EE_Tax_Config(); |
76
|
|
|
parent::__construct($event, $tickets, $max_attendees, $template_args); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
|
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* sets any and all template args that are required for this Ticket Selector |
83
|
|
|
* |
84
|
|
|
* @return void |
85
|
|
|
* @throws \EE_Error |
86
|
|
|
*/ |
87
|
|
|
protected function addTemplateArgs() |
88
|
|
|
{ |
89
|
|
|
$row = 1; |
90
|
|
|
$ticket_row_html = ''; |
91
|
|
|
$required_ticket_sold_out = false; |
92
|
|
|
// flag to indicate that at least one taxable ticket has been encountered |
93
|
|
|
$taxable_tickets = false; |
94
|
|
|
$datetime_selector = new DatetimeSelector( |
95
|
|
|
$this->event, |
96
|
|
|
$this->tickets, |
97
|
|
|
$this->ticket_selector_config, |
98
|
|
|
$this->date_format, |
99
|
|
|
$this->time_format |
100
|
|
|
); |
101
|
|
|
// loop through tickets |
102
|
|
|
foreach ($this->tickets as $TKT_ID => $ticket) { |
103
|
|
|
if ($ticket instanceof \EE_Ticket) { |
104
|
|
|
$cols = 2; |
105
|
|
|
$taxable_tickets = $ticket->taxable() ? true : $taxable_tickets; |
106
|
|
|
$ticket_selector_row = new TicketSelectorRowStandard( |
107
|
|
|
$ticket, |
108
|
|
|
new TicketDetails($ticket, $this->ticket_selector_config, $this->template_args), |
109
|
|
|
$this->ticket_selector_config, |
110
|
|
|
$this->tax_config, |
111
|
|
|
$this->max_attendees, |
112
|
|
|
$row, |
113
|
|
|
$cols, |
114
|
|
|
$required_ticket_sold_out, |
115
|
|
|
$this->template_args['event_status'], |
116
|
|
|
$this->template_args['date_format'], |
117
|
|
|
$datetime_selector->getTicketDatetimeClasses($ticket) |
118
|
|
|
); |
119
|
|
|
$ticket_row_html .= $ticket_selector_row->getHtml(); |
120
|
|
|
$required_ticket_sold_out = $ticket_selector_row->getRequiredTicketSoldOut(); |
121
|
|
|
$row++; |
122
|
|
|
} |
123
|
|
|
} |
124
|
|
|
$this->template_args['row'] = $row; |
125
|
|
|
$this->template_args['ticket_row_html'] = $ticket_row_html; |
126
|
|
|
$this->template_args['taxable_tickets'] = $taxable_tickets; |
127
|
|
|
$this->template_args['datetime_selector'] = $datetime_selector->getDatetimeSelector(); |
128
|
|
|
$this->template_args['prices_displayed_including_taxes'] = $this->tax_config->prices_displayed_including_taxes; |
129
|
|
|
$this->template_args['template_path'] = TICKET_SELECTOR_TEMPLATES_PATH . 'standard_ticket_selector.template.php'; |
130
|
|
|
remove_all_filters('FHEE__EE_Ticket_Selector__hide_ticket_selector'); |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
|
134
|
|
|
|
135
|
|
|
} |
136
|
|
|
// End of file TicketSelectorStandard.php |
137
|
|
|
// Location: EventEspresso\modules\ticket_selector/TicketSelectorStandard.php |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.