@@ -44,7 +44,7 @@ |
||
44 | 44 | ) |
45 | 45 | ); |
46 | 46 | // if the incoming country has a set format, use that, else use the default |
47 | - $formatted_address = $address_formats[ $CNT_ISO ] ?? $address_formats['ZZZ']; |
|
47 | + $formatted_address = $address_formats[$CNT_ISO] ?? $address_formats['ZZZ']; |
|
48 | 48 | return $this->parse_formatted_address( |
49 | 49 | $address, |
50 | 50 | $address2, |
@@ -13,45 +13,45 @@ |
||
13 | 13 | */ |
14 | 14 | class InlineAddressFormatter extends AddressFormatter implements AddressFormatterInterface |
15 | 15 | { |
16 | - /** |
|
17 | - * @param string $address |
|
18 | - * @param string $address2 |
|
19 | - * @param string $city |
|
20 | - * @param string $state |
|
21 | - * @param string $zip |
|
22 | - * @param string $country |
|
23 | - * @param string $CNT_ISO |
|
24 | - * @return string|null |
|
25 | - */ |
|
26 | - public function format( |
|
27 | - string $address, |
|
28 | - string $address2, |
|
29 | - string $city, |
|
30 | - string $state, |
|
31 | - string $zip, |
|
32 | - string $country, |
|
33 | - string $CNT_ISO |
|
34 | - ): ?string { |
|
35 | - $address_formats = apply_filters( |
|
36 | - 'FHEE__EE_Inline_Address_Formatter__address_formats', |
|
37 | - array( |
|
38 | - 'CA' => "{address}%{address2}%{city}%{state}%{country}%{zip}", |
|
39 | - 'GB' => "{address}%{address2}%{city}%{state}%{zip}%{country}", |
|
40 | - 'US' => "{address}%{address2}%{city}%{state}%{zip}%{country}", |
|
41 | - 'ZZZ' => "{address}%{address2}%{city}%{state}%{zip}%{country}", |
|
42 | - ) |
|
43 | - ); |
|
44 | - // if the incoming country has a set format, use that, else use the default |
|
45 | - $formatted_address = $address_formats[ $CNT_ISO ] ?? $address_formats['ZZZ']; |
|
46 | - return $this->parse_formatted_address( |
|
47 | - $address, |
|
48 | - $address2, |
|
49 | - $city, |
|
50 | - $state, |
|
51 | - $zip, |
|
52 | - $country, |
|
53 | - $formatted_address, |
|
54 | - ', ' |
|
55 | - ); |
|
56 | - } |
|
16 | + /** |
|
17 | + * @param string $address |
|
18 | + * @param string $address2 |
|
19 | + * @param string $city |
|
20 | + * @param string $state |
|
21 | + * @param string $zip |
|
22 | + * @param string $country |
|
23 | + * @param string $CNT_ISO |
|
24 | + * @return string|null |
|
25 | + */ |
|
26 | + public function format( |
|
27 | + string $address, |
|
28 | + string $address2, |
|
29 | + string $city, |
|
30 | + string $state, |
|
31 | + string $zip, |
|
32 | + string $country, |
|
33 | + string $CNT_ISO |
|
34 | + ): ?string { |
|
35 | + $address_formats = apply_filters( |
|
36 | + 'FHEE__EE_Inline_Address_Formatter__address_formats', |
|
37 | + array( |
|
38 | + 'CA' => "{address}%{address2}%{city}%{state}%{country}%{zip}", |
|
39 | + 'GB' => "{address}%{address2}%{city}%{state}%{zip}%{country}", |
|
40 | + 'US' => "{address}%{address2}%{city}%{state}%{zip}%{country}", |
|
41 | + 'ZZZ' => "{address}%{address2}%{city}%{state}%{zip}%{country}", |
|
42 | + ) |
|
43 | + ); |
|
44 | + // if the incoming country has a set format, use that, else use the default |
|
45 | + $formatted_address = $address_formats[ $CNT_ISO ] ?? $address_formats['ZZZ']; |
|
46 | + return $this->parse_formatted_address( |
|
47 | + $address, |
|
48 | + $address2, |
|
49 | + $city, |
|
50 | + $state, |
|
51 | + $zip, |
|
52 | + $country, |
|
53 | + $formatted_address, |
|
54 | + ', ' |
|
55 | + ); |
|
56 | + } |
|
57 | 57 | } |
@@ -44,7 +44,7 @@ |
||
44 | 44 | ) |
45 | 45 | ); |
46 | 46 | // if the incoming country has a set format, use that, else use the default |
47 | - $formatted_address = $address_formats[ $CNT_ISO ] ?? $address_formats['ZZ']; |
|
47 | + $formatted_address = $address_formats[$CNT_ISO] ?? $address_formats['ZZ']; |
|
48 | 48 | return $this->parse_formatted_address( |
49 | 49 | $address, |
50 | 50 | $address2, |
@@ -13,45 +13,45 @@ |
||
13 | 13 | */ |
14 | 14 | class MultiLineAddressFormatter extends AddressFormatter implements AddressFormatterInterface |
15 | 15 | { |
16 | - /** |
|
17 | - * @param string $address |
|
18 | - * @param string $address2 |
|
19 | - * @param string $city |
|
20 | - * @param string $state |
|
21 | - * @param string $zip |
|
22 | - * @param string $country |
|
23 | - * @param string $CNT_ISO |
|
24 | - * @return string |
|
25 | - */ |
|
26 | - public function format( |
|
27 | - string $address, |
|
28 | - string $address2, |
|
29 | - string $city, |
|
30 | - string $state, |
|
31 | - string $zip, |
|
32 | - string $country, |
|
33 | - string $CNT_ISO |
|
34 | - ): ?string { |
|
35 | - $address_formats = apply_filters( |
|
36 | - 'FHEE__EE_MultiLine_Address_Formatter__address_formats', |
|
37 | - array( |
|
38 | - 'CA' => "{address}%{address2}%{city}%{state}%{country}%{zip}", |
|
39 | - 'GB' => "{address}%{address2}%{city}%{state}%{zip}%{country}", |
|
40 | - 'US' => "{address}%{address2}%{city}%{state}%{zip}%{country}", |
|
41 | - 'ZZ' => "{address}%{address2}%{city}%{state}%{zip}%{country}", |
|
42 | - ) |
|
43 | - ); |
|
44 | - // if the incoming country has a set format, use that, else use the default |
|
45 | - $formatted_address = $address_formats[ $CNT_ISO ] ?? $address_formats['ZZ']; |
|
46 | - return $this->parse_formatted_address( |
|
47 | - $address, |
|
48 | - $address2, |
|
49 | - $city, |
|
50 | - $state, |
|
51 | - $zip, |
|
52 | - $country, |
|
53 | - $formatted_address, |
|
54 | - '<br />' |
|
55 | - ); |
|
56 | - } |
|
16 | + /** |
|
17 | + * @param string $address |
|
18 | + * @param string $address2 |
|
19 | + * @param string $city |
|
20 | + * @param string $state |
|
21 | + * @param string $zip |
|
22 | + * @param string $country |
|
23 | + * @param string $CNT_ISO |
|
24 | + * @return string |
|
25 | + */ |
|
26 | + public function format( |
|
27 | + string $address, |
|
28 | + string $address2, |
|
29 | + string $city, |
|
30 | + string $state, |
|
31 | + string $zip, |
|
32 | + string $country, |
|
33 | + string $CNT_ISO |
|
34 | + ): ?string { |
|
35 | + $address_formats = apply_filters( |
|
36 | + 'FHEE__EE_MultiLine_Address_Formatter__address_formats', |
|
37 | + array( |
|
38 | + 'CA' => "{address}%{address2}%{city}%{state}%{country}%{zip}", |
|
39 | + 'GB' => "{address}%{address2}%{city}%{state}%{zip}%{country}", |
|
40 | + 'US' => "{address}%{address2}%{city}%{state}%{zip}%{country}", |
|
41 | + 'ZZ' => "{address}%{address2}%{city}%{state}%{zip}%{country}", |
|
42 | + ) |
|
43 | + ); |
|
44 | + // if the incoming country has a set format, use that, else use the default |
|
45 | + $formatted_address = $address_formats[ $CNT_ISO ] ?? $address_formats['ZZ']; |
|
46 | + return $this->parse_formatted_address( |
|
47 | + $address, |
|
48 | + $address2, |
|
49 | + $city, |
|
50 | + $state, |
|
51 | + $zip, |
|
52 | + $country, |
|
53 | + $formatted_address, |
|
54 | + '<br />' |
|
55 | + ); |
|
56 | + } |
|
57 | 57 | } |
@@ -12,38 +12,38 @@ |
||
12 | 12 | */ |
13 | 13 | class AddressFormatter |
14 | 14 | { |
15 | - // phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
16 | - /** |
|
17 | - * @param string $address |
|
18 | - * @param string $address2 |
|
19 | - * @param string $city |
|
20 | - * @param string $state |
|
21 | - * @param string $zip |
|
22 | - * @param string $country |
|
23 | - * @param string $formatted_address |
|
24 | - * @param string $sub |
|
25 | - * @return string |
|
26 | - */ |
|
27 | - protected function parse_formatted_address( |
|
28 | - string $address, |
|
29 | - string $address2, |
|
30 | - string $city, |
|
31 | - string $state, |
|
32 | - string $zip, |
|
33 | - string $country, |
|
34 | - string $formatted_address, |
|
35 | - string $sub |
|
36 | - ): string { |
|
37 | - // swap address part placeholders for the real text |
|
38 | - $formatted_address = str_replace( |
|
39 | - // find |
|
40 | - array('{address}', '{address2}', '{city}', '{state}', '{zip}', '{country}'), |
|
41 | - // replace |
|
42 | - array($address, $address2, $city, $state, $zip, $country), |
|
43 | - // string |
|
44 | - $formatted_address |
|
45 | - ); |
|
46 | - // remove placeholder from start and end, reduce repeating placeholders to singles, then replace with HTML line breaks |
|
47 | - return preg_replace('/%+/', $sub, trim($formatted_address, '%')); |
|
48 | - } |
|
15 | + // phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
16 | + /** |
|
17 | + * @param string $address |
|
18 | + * @param string $address2 |
|
19 | + * @param string $city |
|
20 | + * @param string $state |
|
21 | + * @param string $zip |
|
22 | + * @param string $country |
|
23 | + * @param string $formatted_address |
|
24 | + * @param string $sub |
|
25 | + * @return string |
|
26 | + */ |
|
27 | + protected function parse_formatted_address( |
|
28 | + string $address, |
|
29 | + string $address2, |
|
30 | + string $city, |
|
31 | + string $state, |
|
32 | + string $zip, |
|
33 | + string $country, |
|
34 | + string $formatted_address, |
|
35 | + string $sub |
|
36 | + ): string { |
|
37 | + // swap address part placeholders for the real text |
|
38 | + $formatted_address = str_replace( |
|
39 | + // find |
|
40 | + array('{address}', '{address2}', '{city}', '{state}', '{zip}', '{country}'), |
|
41 | + // replace |
|
42 | + array($address, $address2, $city, $state, $zip, $country), |
|
43 | + // string |
|
44 | + $formatted_address |
|
45 | + ); |
|
46 | + // remove placeholder from start and end, reduce repeating placeholders to singles, then replace with HTML line breaks |
|
47 | + return preg_replace('/%+/', $sub, trim($formatted_address, '%')); |
|
48 | + } |
|
49 | 49 | } |
@@ -21,28 +21,28 @@ discard block |
||
21 | 21 | use EventEspresso\modules\ticket_selector\TicketDetails; |
22 | 22 | |
23 | 23 | $event_date_label = apply_filters( |
24 | - 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_event_date', |
|
25 | - esc_html__('Event Date ', 'event_espresso') |
|
24 | + 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_event_date', |
|
25 | + esc_html__('Event Date ', 'event_espresso') |
|
26 | 26 | ); |
27 | 27 | |
28 | 28 | $sold_label = apply_filters( |
29 | - 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_sold', |
|
30 | - esc_html__('Sold', 'event_espresso') |
|
29 | + 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_sold', |
|
30 | + esc_html__('Sold', 'event_espresso') |
|
31 | 31 | ); |
32 | 32 | |
33 | 33 | $remaining_label = apply_filters( |
34 | - 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_left', |
|
35 | - esc_html__('Remaining', 'event_espresso') |
|
34 | + 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_left', |
|
35 | + esc_html__('Remaining', 'event_espresso') |
|
36 | 36 | ); |
37 | 37 | |
38 | 38 | $total_sold_label = apply_filters( |
39 | - 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_sold', |
|
40 | - esc_html__('Total Sold', 'event_espresso') |
|
39 | + 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_sold', |
|
40 | + esc_html__('Total Sold', 'event_espresso') |
|
41 | 41 | ); |
42 | 42 | |
43 | 43 | $spaces_left_label = apply_filters( |
44 | - 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_left', |
|
45 | - esc_html__('Total Spaces Left', 'event_espresso') |
|
44 | + 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_left', |
|
45 | + esc_html__('Total Spaces Left', 'event_espresso') |
|
46 | 46 | ); |
47 | 47 | |
48 | 48 | ?> |
@@ -56,32 +56,32 @@ discard block |
||
56 | 56 | <p><?php echo wp_kses($ticket->description(), AllowedTags::getAllowedTags()); ?></p> |
57 | 57 | |
58 | 58 | <?php |
59 | - do_action( |
|
60 | - 'AHEE__ticket_selector_chart_template__ticket_details__after_description', |
|
61 | - $ticket, |
|
62 | - $ticket_price, |
|
63 | - $display_ticket_price |
|
64 | - ); |
|
65 | - ?> |
|
59 | + do_action( |
|
60 | + 'AHEE__ticket_selector_chart_template__ticket_details__after_description', |
|
61 | + $ticket, |
|
62 | + $ticket_price, |
|
63 | + $display_ticket_price |
|
64 | + ); |
|
65 | + ?> |
|
66 | 66 | <section class="tckt-slctr-tkt-sale-dates-sctn"> |
67 | 67 | <h5> |
68 | 68 | <?php echo apply_filters( |
69 | - 'FHEE__ticket_selector_chart_template__ticket_details_sales_date_heading', |
|
70 | - esc_html__('Sale Dates', 'event_espresso') |
|
71 | - ); ?> |
|
69 | + 'FHEE__ticket_selector_chart_template__ticket_details_sales_date_heading', |
|
70 | + esc_html__('Sale Dates', 'event_espresso') |
|
71 | + ); ?> |
|
72 | 72 | </h5> |
73 | 73 | <span class="drk-grey-text small-text no-bold"> - |
74 | 74 | <?php echo apply_filters( |
75 | - 'FHEE__ticket_selector_chart_template__ticket_details_dates_available_message', |
|
76 | - esc_html__('The dates when this option is available for purchase.', 'event_espresso') |
|
77 | - ); ?> |
|
75 | + 'FHEE__ticket_selector_chart_template__ticket_details_dates_available_message', |
|
76 | + esc_html__('The dates when this option is available for purchase.', 'event_espresso') |
|
77 | + ); ?> |
|
78 | 78 | </span> |
79 | 79 | <br /> |
80 | 80 | <span class="ticket-details-label-spn drk-grey-text"> |
81 | 81 | <?php echo apply_filters( |
82 | - 'FHEE__ticket_selector_chart_template__ticket_details_goes_on_sale', |
|
83 | - esc_html__('Goes On Sale:', 'event_espresso') |
|
84 | - ); ?> |
|
82 | + 'FHEE__ticket_selector_chart_template__ticket_details_goes_on_sale', |
|
83 | + esc_html__('Goes On Sale:', 'event_espresso') |
|
84 | + ); ?> |
|
85 | 85 | </span> |
86 | 86 | <span class="dashicons dashicons-calendar"></span> |
87 | 87 | <?php echo esc_html($ticket->get_i18n_datetime('TKT_start_date', $date_format)) . ' '; ?> |
@@ -90,9 +90,9 @@ discard block |
||
90 | 90 | <br /> |
91 | 91 | <span class="ticket-details-label-spn drk-grey-text"> |
92 | 92 | <?php echo apply_filters( |
93 | - 'FHEE__ticket_selector_chart_template__ticket_details_sales_end', |
|
94 | - esc_html__('Sales End:', 'event_espresso') |
|
95 | - ); ?> |
|
93 | + 'FHEE__ticket_selector_chart_template__ticket_details_sales_end', |
|
94 | + esc_html__('Sales End:', 'event_espresso') |
|
95 | + ); ?> |
|
96 | 96 | </span> |
97 | 97 | <span class="dashicons dashicons-calendar"></span> |
98 | 98 | <?php echo esc_html($ticket->get_i18n_datetime('TKT_end_date', $date_format)) . ' '; ?> |
@@ -108,55 +108,55 @@ discard block |
||
108 | 108 | <section class="tckt-slctr-tkt-quantities-sctn"> |
109 | 109 | <h5> |
110 | 110 | <?php echo apply_filters( |
111 | - 'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_heading', |
|
112 | - esc_html__('Purchasable Quantities', 'event_espresso') |
|
113 | - ); ?> |
|
111 | + 'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_heading', |
|
112 | + esc_html__('Purchasable Quantities', 'event_espresso') |
|
113 | + ); ?> |
|
114 | 114 | </h5> |
115 | 115 | <span class="drk-grey-text small-text no-bold"> - |
116 | 116 | <?php echo apply_filters( |
117 | - 'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_message', |
|
118 | - esc_html__( |
|
119 | - 'The number of tickets that can be purchased per transaction (if available).', |
|
120 | - 'event_espresso' |
|
121 | - ) |
|
122 | - ); ?> |
|
117 | + 'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_message', |
|
118 | + esc_html__( |
|
119 | + 'The number of tickets that can be purchased per transaction (if available).', |
|
120 | + 'event_espresso' |
|
121 | + ) |
|
122 | + ); ?> |
|
123 | 123 | </span> |
124 | 124 | <br /> |
125 | 125 | <span class="ticket-details-label-spn drk-grey-text"> |
126 | 126 | <?php echo apply_filters( |
127 | - 'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_min_qty', |
|
128 | - esc_html__('Minimum Qty:', 'event_espresso') |
|
129 | - ); ?> |
|
127 | + 'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_min_qty', |
|
128 | + esc_html__('Minimum Qty:', 'event_espresso') |
|
129 | + ); ?> |
|
130 | 130 | </span> |
131 | 131 | <?php |
132 | - echo esc_html($ticket->min() > 0 ? $ticket->min() : 0); |
|
132 | + echo esc_html($ticket->min() > 0 ? $ticket->min() : 0); |
|
133 | 133 | |
134 | - if ($ticket->min() > $remaining) { |
|
135 | - ?> |
|
134 | + if ($ticket->min() > $remaining) { |
|
135 | + ?> |
|
136 | 136 | <span class="important-notice small-text"> |
137 | 137 | <?php echo apply_filters( |
138 | - 'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_min_qty_message', |
|
139 | - esc_html__( |
|
140 | - 'The Minimum Quantity purchasable for this ticket exceeds the number of spaces remaining', |
|
141 | - 'event_espresso' |
|
142 | - ) |
|
143 | - ); ?> |
|
138 | + 'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_min_qty_message', |
|
139 | + esc_html__( |
|
140 | + 'The Minimum Quantity purchasable for this ticket exceeds the number of spaces remaining', |
|
141 | + 'event_espresso' |
|
142 | + ) |
|
143 | + ); ?> |
|
144 | 144 | </span> |
145 | 145 | <?php } ?> |
146 | 146 | <br /> |
147 | 147 | <?php // $max = min( $max, $max_atndz );?> |
148 | 148 | <span class="ticket-details-label-spn drk-grey-text"> |
149 | 149 | <?php echo apply_filters( |
150 | - 'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_max_qty', |
|
151 | - esc_html__('Maximum Qty:', 'event_espresso') |
|
152 | - ); ?> |
|
150 | + 'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_max_qty', |
|
151 | + esc_html__('Maximum Qty:', 'event_espresso') |
|
152 | + ); ?> |
|
153 | 153 | </span> |
154 | 154 | <?php echo esc_html( |
155 | - $ticket->max() === EE_INF |
|
156 | - ? __('no limit', 'event_espresso') |
|
157 | - : max($ticket->max(), 1) |
|
158 | - ); |
|
159 | - ?> |
|
155 | + $ticket->max() === EE_INF |
|
156 | + ? __('no limit', 'event_espresso') |
|
157 | + : max($ticket->max(), 1) |
|
158 | + ); |
|
159 | + ?> |
|
160 | 160 | <br /> |
161 | 161 | </section> |
162 | 162 | <br /> |
@@ -166,31 +166,31 @@ discard block |
||
166 | 166 | <section class="tckt-slctr-tkt-uses-sctn"> |
167 | 167 | <h5> |
168 | 168 | <?php echo apply_filters( |
169 | - 'FHEE__ticket_selector_chart_template__ticket_details_event_date_ticket_uses_heading', |
|
170 | - esc_html__('Event Date Ticket Uses', 'event_espresso') |
|
171 | - ); ?> |
|
169 | + 'FHEE__ticket_selector_chart_template__ticket_details_event_date_ticket_uses_heading', |
|
170 | + esc_html__('Event Date Ticket Uses', 'event_espresso') |
|
171 | + ); ?> |
|
172 | 172 | </h5> |
173 | 173 | <span class="drk-grey-text small-text no-bold"> - |
174 | 174 | <?php echo apply_filters( |
175 | - 'FHEE__ticket_selector_chart_template__ticket_details_event_date_ticket_uses_message', |
|
176 | - sprintf( |
|
177 | - esc_html__( |
|
178 | - 'The number of separate event datetimes (see table below) that this ticket can be used to gain admittance to.%1$s%2$sAdmission is always one person per ticket.%3$s', |
|
179 | - 'event_espresso' |
|
180 | - ), |
|
181 | - '<br/>', |
|
182 | - '<strong>', |
|
183 | - '</strong>' |
|
184 | - ) |
|
185 | - ); |
|
186 | - ?> |
|
175 | + 'FHEE__ticket_selector_chart_template__ticket_details_event_date_ticket_uses_message', |
|
176 | + sprintf( |
|
177 | + esc_html__( |
|
178 | + 'The number of separate event datetimes (see table below) that this ticket can be used to gain admittance to.%1$s%2$sAdmission is always one person per ticket.%3$s', |
|
179 | + 'event_espresso' |
|
180 | + ), |
|
181 | + '<br/>', |
|
182 | + '<strong>', |
|
183 | + '</strong>' |
|
184 | + ) |
|
185 | + ); |
|
186 | + ?> |
|
187 | 187 | </span> |
188 | 188 | <br /> |
189 | 189 | <span class="ticket-details-label-spn drk-grey-text"> |
190 | 190 | <?php echo apply_filters( |
191 | - 'FHEE__ticket_selector_chart_template__ticket_details_event_date_number_datetimes', |
|
192 | - esc_html__('# Datetimes:', 'event_espresso') |
|
193 | - ); ?> |
|
191 | + 'FHEE__ticket_selector_chart_template__ticket_details_event_date_number_datetimes', |
|
192 | + esc_html__('# Datetimes:', 'event_espresso') |
|
193 | + ); ?> |
|
194 | 194 | </span> |
195 | 195 | <?php echo wp_kses($ticket->uses(), AllowedTags::getAllowedTags()); ?> |
196 | 196 | <br /> |
@@ -198,24 +198,24 @@ discard block |
||
198 | 198 | <?php } ?> |
199 | 199 | |
200 | 200 | <?php |
201 | - $datetimes = $ticket->datetimes_ordered($event_is_expired, false); |
|
202 | - $chart_column_width = $show_ticket_sale_columns ? ' ee-fourth-width' : ' ee-half-width'; |
|
203 | - if (! empty($datetimes)) { ?> |
|
201 | + $datetimes = $ticket->datetimes_ordered($event_is_expired, false); |
|
202 | + $chart_column_width = $show_ticket_sale_columns ? ' ee-fourth-width' : ' ee-half-width'; |
|
203 | + if (! empty($datetimes)) { ?> |
|
204 | 204 | <section class="tckt-slctr-tkt-datetimes-sctn"> |
205 | 205 | <h5> |
206 | 206 | <?php echo apply_filters( |
207 | - 'FHEE__ticket_selector_chart_template__ticket_details_event_access_heading', |
|
208 | - esc_html__('Access', 'event_espresso') |
|
209 | - ); ?> |
|
207 | + 'FHEE__ticket_selector_chart_template__ticket_details_event_access_heading', |
|
208 | + esc_html__('Access', 'event_espresso') |
|
209 | + ); ?> |
|
210 | 210 | </h5> |
211 | 211 | <span class="drk-grey-text small-text no-bold"> - |
212 | 212 | <?php echo apply_filters( |
213 | - 'FHEE__ticket_selector_chart_template__ticket_details_event_access_message', |
|
214 | - esc_html__( |
|
215 | - 'This option allows access to the following dates and times.', |
|
216 | - 'event_espresso' |
|
217 | - ) |
|
218 | - ); ?> |
|
213 | + 'FHEE__ticket_selector_chart_template__ticket_details_event_access_message', |
|
214 | + esc_html__( |
|
215 | + 'This option allows access to the following dates and times.', |
|
216 | + 'event_espresso' |
|
217 | + ) |
|
218 | + ); ?> |
|
219 | 219 | </span> |
220 | 220 | <div class="tckt-slctr-tkt-details-tbl-wrap-dv"> |
221 | 221 | <table class="tckt-slctr-tkt-details-tbl"> |
@@ -225,9 +225,9 @@ discard block |
||
225 | 225 | <span class="dashicons dashicons-calendar"></span> |
226 | 226 | <span class="small-text"> |
227 | 227 | <?php echo apply_filters( |
228 | - 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_event_date', |
|
229 | - esc_html__('Date ', 'event_espresso') |
|
230 | - ); ?> |
|
228 | + 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_event_date', |
|
229 | + esc_html__('Date ', 'event_espresso') |
|
230 | + ); ?> |
|
231 | 231 | </span> |
232 | 232 | </th> |
233 | 233 | <th class="tckt-slctr-tkt-details-time-th <?php echo esc_attr($chart_column_width); ?>"> |
@@ -240,33 +240,33 @@ discard block |
||
240 | 240 | <th class="tckt-slctr-tkt-details-this-ticket-sold-th ee-fourth-width cntr"> |
241 | 241 | <span class="smaller-text"> |
242 | 242 | <?php echo apply_filters( |
243 | - 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_sold', |
|
244 | - sprintf(esc_html__('Sold', 'event_espresso'), '<br/>') |
|
245 | - ); ?> |
|
243 | + 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_sold', |
|
244 | + sprintf(esc_html__('Sold', 'event_espresso'), '<br/>') |
|
245 | + ); ?> |
|
246 | 246 | </span> |
247 | 247 | </th> |
248 | 248 | <th class="tckt-slctr-tkt-details-this-ticket-left-th ee-fourth-width cntr"> |
249 | 249 | <span class="smaller-text"> |
250 | 250 | <?php echo apply_filters( |
251 | - 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_left', |
|
252 | - sprintf(esc_html__('Remaining', 'event_espresso'), '<br/>') |
|
253 | - ); ?> |
|
251 | + 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_left', |
|
252 | + sprintf(esc_html__('Remaining', 'event_espresso'), '<br/>') |
|
253 | + ); ?> |
|
254 | 254 | </span> |
255 | 255 | </th> |
256 | 256 | <th class="tckt-slctr-tkt-details-total-tickets-sold-th ee-fourth-width cntr"> |
257 | 257 | <span class="smaller-text"> |
258 | 258 | <?php echo apply_filters( |
259 | - 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_sold', |
|
260 | - sprintf(esc_html__('Total%sSold', 'event_espresso'), '<br/>') |
|
261 | - ); ?> |
|
259 | + 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_sold', |
|
260 | + sprintf(esc_html__('Total%sSold', 'event_espresso'), '<br/>') |
|
261 | + ); ?> |
|
262 | 262 | </span> |
263 | 263 | </th> |
264 | 264 | <th class="tckt-slctr-tkt-details-total-tickets-left-th ee-fourth-width cntr"> |
265 | 265 | <span class="smaller-text"> |
266 | 266 | <?php echo apply_filters( |
267 | - 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_left', |
|
268 | - sprintf(esc_html__('Total Spaces%sLeft', 'event_espresso'), '<br/>') |
|
269 | - ); ?> |
|
267 | + 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_left', |
|
268 | + sprintf(esc_html__('Total Spaces%sLeft', 'event_espresso'), '<br/>') |
|
269 | + ); ?> |
|
270 | 270 | </span> |
271 | 271 | </th> |
272 | 272 | <?php endif; // end $show_ticket_sale_columns conditional ?> |
@@ -274,25 +274,25 @@ discard block |
||
274 | 274 | </thead> |
275 | 275 | <tbody> |
276 | 276 | <?php foreach ($datetimes as $datetime) { |
277 | - if ($datetime instanceof EE_Datetime) { ?> |
|
277 | + if ($datetime instanceof EE_Datetime) { ?> |
|
278 | 278 | <tr> |
279 | 279 | <td data-th="<?php echo esc_attr($event_date_label); ?>" class="small-text"> |
280 | 280 | <?php $datetime_name = $datetime->name(); ?> |
281 | 281 | <?php echo ! empty($datetime_name) |
282 | - ? '<b>' . esc_html($datetime_name) . '</b><br/>' |
|
283 | - : ''; ?> |
|
282 | + ? '<b>' . esc_html($datetime_name) . '</b><br/>' |
|
283 | + : ''; ?> |
|
284 | 284 | <?php echo esc_html($datetime->date_range( |
285 | - $date_format, |
|
286 | - esc_html__(' to ', 'event_espresso') |
|
287 | - )); ?> |
|
285 | + $date_format, |
|
286 | + esc_html__(' to ', 'event_espresso') |
|
287 | + )); ?> |
|
288 | 288 | </td> |
289 | 289 | <td data-th="<?php esc_html_e('Time ', 'event_espresso'); ?>" |
290 | 290 | class="cntr small-text" |
291 | 291 | > |
292 | 292 | <?php echo esc_html($datetime->time_range( |
293 | - $time_format, |
|
294 | - esc_html__(' to ', 'event_espresso') |
|
295 | - )); ?> |
|
293 | + $time_format, |
|
294 | + esc_html__(' to ', 'event_espresso') |
|
295 | + )); ?> |
|
296 | 296 | </td> |
297 | 297 | <?php if ($show_ticket_sale_columns) : ?> |
298 | 298 | <td data-th="<?php echo esc_attr($sold_label); ?>" class="cntr small-text"> |
@@ -300,31 +300,31 @@ discard block |
||
300 | 300 | </td> |
301 | 301 | <td data-th="<?php echo esc_attr($remaining_label); ?>" class="cntr small-text"> |
302 | 302 | <?php echo wp_kses( |
303 | - $remaining === EE_INF |
|
304 | - ? '<span class="smaller-text">' |
|
305 | - . esc_html__('unlimited ', 'event_espresso') |
|
306 | - . '</span>' |
|
307 | - : $remaining, |
|
308 | - AllowedTags::getAllowedTags() |
|
309 | - ); ?> |
|
303 | + $remaining === EE_INF |
|
304 | + ? '<span class="smaller-text">' |
|
305 | + . esc_html__('unlimited ', 'event_espresso') |
|
306 | + . '</span>' |
|
307 | + : $remaining, |
|
308 | + AllowedTags::getAllowedTags() |
|
309 | + ); ?> |
|
310 | 310 | </td> |
311 | 311 | <td data-th="<?php echo esc_attr($total_sold_label); ?>" class="cntr small-text"> |
312 | 312 | <?php echo esc_html($datetime->sold()); ?> |
313 | 313 | </td> |
314 | 314 | <?php $tkts_left = $datetime->sold_out() |
315 | - ? '<span class="sold-out smaller-text">' |
|
316 | - . esc_html__('Sold Out', 'event_espresso') |
|
317 | - . '</span>' |
|
318 | - : $datetime->spaces_remaining(); ?> |
|
315 | + ? '<span class="sold-out smaller-text">' |
|
316 | + . esc_html__('Sold Out', 'event_espresso') |
|
317 | + . '</span>' |
|
318 | + : $datetime->spaces_remaining(); ?> |
|
319 | 319 | <td data-th="<?php echo esc_attr($spaces_left_label); ?>" class="cntr small-text"> |
320 | 320 | <?php echo wp_kses( |
321 | - $tkts_left === EE_INF |
|
322 | - ? '<span class="smaller-text">' |
|
323 | - . esc_html__('unlimited ', 'event_espresso') |
|
324 | - . '</span>' |
|
325 | - : $tkts_left, |
|
326 | - AllowedTags::getAllowedTags() |
|
327 | - ); ?> |
|
321 | + $tkts_left === EE_INF |
|
322 | + ? '<span class="smaller-text">' |
|
323 | + . esc_html__('unlimited ', 'event_espresso') |
|
324 | + . '</span>' |
|
325 | + : $tkts_left, |
|
326 | + AllowedTags::getAllowedTags() |
|
327 | + ); ?> |
|
328 | 328 | </td> |
329 | 329 | <?php endif; // end $show_ticket_sale_columns conditional ?> |
330 | 330 | </tr> |
@@ -76,20 +76,20 @@ discard block |
||
76 | 76 | </thead> |
77 | 77 | <tbody> |
78 | 78 | <?php |
79 | - /** |
|
80 | - * Recursive function for traversing all the sub-items of each line item |
|
81 | - * and displaying them in the table |
|
82 | - * |
|
83 | - * @param EE_Line_Item $line_item |
|
84 | - * @param boolean $odd for indicating whether to style this line item as an 'odd' or 'even' |
|
85 | - */ |
|
86 | - function ee_invoice_display_line_item(EE_Line_Item $line_item, $show_line_item_description, $odd = false) |
|
87 | - { |
|
88 | - switch ($line_item->type()) { |
|
89 | - case EEM_Line_Item::type_total: |
|
90 | - foreach ($line_item->children() as $child_line_item) { |
|
91 | - ee_invoice_display_line_item($child_line_item, $show_line_item_description); |
|
92 | - } ?> |
|
79 | + /** |
|
80 | + * Recursive function for traversing all the sub-items of each line item |
|
81 | + * and displaying them in the table |
|
82 | + * |
|
83 | + * @param EE_Line_Item $line_item |
|
84 | + * @param boolean $odd for indicating whether to style this line item as an 'odd' or 'even' |
|
85 | + */ |
|
86 | + function ee_invoice_display_line_item(EE_Line_Item $line_item, $show_line_item_description, $odd = false) |
|
87 | + { |
|
88 | + switch ($line_item->type()) { |
|
89 | + case EEM_Line_Item::type_total: |
|
90 | + foreach ($line_item->children() as $child_line_item) { |
|
91 | + ee_invoice_display_line_item($child_line_item, $show_line_item_description); |
|
92 | + } ?> |
|
93 | 93 | <tr> |
94 | 94 | <td colspan="<?php echo esc_attr($show_line_item_description ? 5 : 4); ?>"> |
95 | 95 | <hr> |
@@ -101,50 +101,50 @@ discard block |
||
101 | 101 | <td class="total"><?php echo wp_kses($line_item->total_no_code(), AllowedTags::getAllowedTags()); ?></td> |
102 | 102 | </tr> |
103 | 103 | <?php |
104 | - break; |
|
104 | + break; |
|
105 | 105 | |
106 | 106 | |
107 | - case EEM_Line_Item::type_sub_total: |
|
108 | - foreach ($line_item->children() as $child_line_item) { |
|
109 | - // $odd = !$odd; |
|
110 | - ee_invoice_display_line_item($child_line_item, $show_line_item_description, $odd); |
|
111 | - } ?> |
|
107 | + case EEM_Line_Item::type_sub_total: |
|
108 | + foreach ($line_item->children() as $child_line_item) { |
|
109 | + // $odd = !$odd; |
|
110 | + ee_invoice_display_line_item($child_line_item, $show_line_item_description, $odd); |
|
111 | + } ?> |
|
112 | 112 | <tr class="total_tr odd"> |
113 | 113 | <td colspan="<?php echo esc_attr($show_line_item_description ? 2 : 1); ?>"> </td> |
114 | 114 | <td colspan="2" class="total" id="total_currency"> |
115 | 115 | <?php esc_html_e( |
116 | - 'Sub-Total', |
|
117 | - 'event_espresso' |
|
118 | - ); ?></td> |
|
116 | + 'Sub-Total', |
|
117 | + 'event_espresso' |
|
118 | + ); ?></td> |
|
119 | 119 | <td class="total"><?php echo wp_kses($line_item->total_no_code(), AllowedTags::getAllowedTags()); ?></td> |
120 | 120 | </tr> |
121 | 121 | <?php |
122 | - break; |
|
122 | + break; |
|
123 | 123 | |
124 | 124 | |
125 | - case EEM_Line_Item::type_tax_sub_total: |
|
126 | - foreach ($line_item->children() as $child_line_item) { |
|
127 | - $odd = ! $odd; |
|
128 | - ee_invoice_display_line_item($child_line_item, $show_line_item_description, $odd); |
|
129 | - } ?> |
|
125 | + case EEM_Line_Item::type_tax_sub_total: |
|
126 | + foreach ($line_item->children() as $child_line_item) { |
|
127 | + $odd = ! $odd; |
|
128 | + ee_invoice_display_line_item($child_line_item, $show_line_item_description, $odd); |
|
129 | + } ?> |
|
130 | 130 | <tr class="total_tr odd"> |
131 | 131 | <td colspan="<?php echo esc_attr($show_line_item_description ? 2 : 1); ?>"> </td> |
132 | 132 | <td colspan="2" class="total" id="total_currency"> |
133 | 133 | <?php esc_html_e( |
134 | - 'Tax Total', |
|
135 | - 'event_espresso' |
|
136 | - ); ?></td> |
|
134 | + 'Tax Total', |
|
135 | + 'event_espresso' |
|
136 | + ); ?></td> |
|
137 | 137 | <td class="total"><?php echo wp_kses($line_item->total_no_code(), AllowedTags::getAllowedTags()); ?></td> |
138 | 138 | </tr> |
139 | 139 | <?php |
140 | - break; |
|
140 | + break; |
|
141 | 141 | |
142 | 142 | |
143 | - case EEM_Line_Item::type_line_item: |
|
144 | - $subitems = $line_item->children(); |
|
145 | - $has_subitems = count($subitems) > 1; |
|
146 | - if ($has_subitems) { |
|
147 | - ?> |
|
143 | + case EEM_Line_Item::type_line_item: |
|
144 | + $subitems = $line_item->children(); |
|
145 | + $has_subitems = count($subitems) > 1; |
|
146 | + if ($has_subitems) { |
|
147 | + ?> |
|
148 | 148 | <tr class="item <?php echo sanitize_html_class($odd ? 'odd' : ''); ?>"> |
149 | 149 | <td class="item_l"><?php echo esc_html($line_item->name()) ?></td> |
150 | 150 | <?php if ($show_line_item_description) { ?> |
@@ -155,18 +155,18 @@ discard block |
||
155 | 155 | <td class="item_c"><?php echo esc_html($line_item->unit_price_no_code()) ?></td> |
156 | 156 | |
157 | 157 | <td class="item_r"> <?php echo wp_kses($line_item->total_no_code(), AllowedTags::getAllowedTags()); |
158 | - echo esc_html($line_item->is_taxable() ? '*' : ''); ?> </td> |
|
158 | + echo esc_html($line_item->is_taxable() ? '*' : ''); ?> </td> |
|
159 | 159 | <?php // <td class="item_l"><?php $datetimes_strings = array(); foreach($datetimes as $datetime){ $datetimes_strings[]= $datetime->start_date_and_time();} echo implode(", ",$datetimes_strings); |
160 | - ?> |
|
160 | + ?> |
|
161 | 161 | </tr> |
162 | 162 | <?php |
163 | - if ($has_subitems) { |
|
164 | - foreach ($line_item->children() as $child_line_item) { |
|
165 | - ee_invoice_display_line_item($child_line_item, $show_line_item_description, $odd); |
|
166 | - } |
|
167 | - } |
|
168 | - } else {// no subitems - just show this line item |
|
169 | - ?> |
|
163 | + if ($has_subitems) { |
|
164 | + foreach ($line_item->children() as $child_line_item) { |
|
165 | + ee_invoice_display_line_item($child_line_item, $show_line_item_description, $odd); |
|
166 | + } |
|
167 | + } |
|
168 | + } else {// no subitems - just show this line item |
|
169 | + ?> |
|
170 | 170 | <tr class="item <?php echo sanitize_html_class($odd ? 'odd' : ''); ?>"> |
171 | 171 | <td class="item_l"><?php echo esc_html($line_item->name()); ?></td> |
172 | 172 | <?php if ($show_line_item_description) { ?> |
@@ -175,15 +175,15 @@ discard block |
||
175 | 175 | <td class="item_l"><?php echo esc_html($line_item->quantity()); ?></td> |
176 | 176 | <td class="item_c"><?php echo wp_kses($line_item->unit_price_no_code(), AllowedTags::getAllowedTags()); ?></td> |
177 | 177 | <td class="item_r"> <?php echo wp_kses($line_item->total_no_code(), AllowedTags::getAllowedTags()); |
178 | - echo esc_html($line_item->is_taxable() ? '*' : ''); ?> </td> |
|
178 | + echo esc_html($line_item->is_taxable() ? '*' : ''); ?> </td> |
|
179 | 179 | <?php // <td class="item_l"><?php $datetimes_strings = array(); foreach($datetimes as $datetime){ $datetimes_strings[]= $datetime->start_date_and_time();} echo implode(", ",$datetimes_strings); |
180 | - ?> |
|
180 | + ?> |
|
181 | 181 | </tr> |
182 | 182 | <?php } |
183 | 183 | |
184 | - break; |
|
185 | - case EEM_Line_Item::type_sub_line_item: |
|
186 | - ?> |
|
184 | + break; |
|
185 | + case EEM_Line_Item::type_sub_line_item: |
|
186 | + ?> |
|
187 | 187 | <tr class="item subitem-row"> |
188 | 188 | <td class="item_l subitem"><?php echo esc_html($line_item->name()); ?></td> |
189 | 189 | <?php if ($show_line_item_description) { ?> |
@@ -199,9 +199,9 @@ discard block |
||
199 | 199 | <td class="item_r"><?php echo wp_kses($line_item->total_no_code(), AllowedTags::getAllowedTags()); ?></td> |
200 | 200 | </tr> |
201 | 201 | <?php |
202 | - break; |
|
203 | - case EEM_Line_Item::type_tax: |
|
204 | - ?> |
|
202 | + break; |
|
203 | + case EEM_Line_Item::type_tax: |
|
204 | + ?> |
|
205 | 205 | <tr class="item sub-item tax-total"> |
206 | 206 | <td class="item_l"><?php echo esc_html($line_item->name()); ?></td> |
207 | 207 | <?php if ($show_line_item_description) { ?> |
@@ -211,15 +211,15 @@ discard block |
||
211 | 211 | |
212 | 212 | <td class="item_r"><?php echo wp_kses($line_item->total_no_code(), AllowedTags::getAllowedTags()); ?></td> |
213 | 213 | </tr><?php |
214 | - break; |
|
215 | - } |
|
216 | - } |
|
214 | + break; |
|
215 | + } |
|
216 | + } |
|
217 | 217 | |
218 | - $c = false; |
|
219 | - /* @var $transaction EE_Transaction */ |
|
220 | - $total_line_item = $transaction->total_line_item(); |
|
221 | - ee_invoice_display_line_item($total_line_item, $show_line_item_description); |
|
222 | - ?> |
|
218 | + $c = false; |
|
219 | + /* @var $transaction EE_Transaction */ |
|
220 | + $total_line_item = $transaction->total_line_item(); |
|
221 | + ee_invoice_display_line_item($total_line_item, $show_line_item_description); |
|
222 | + ?> |
|
223 | 223 | </tbody> |
224 | 224 | |
225 | 225 | </table> |
@@ -238,11 +238,11 @@ discard block |
||
238 | 238 | </thead> |
239 | 239 | <tbody> |
240 | 240 | <?php |
241 | - $c = false; |
|
242 | - if (! empty($payments)) { |
|
243 | - foreach ($payments as $payment) { |
|
244 | - /* @var $payment EE_Payment */ |
|
245 | - ?> |
|
241 | + $c = false; |
|
242 | + if (! empty($payments)) { |
|
243 | + foreach ($payments as $payment) { |
|
244 | + /* @var $payment EE_Payment */ |
|
245 | + ?> |
|
246 | 246 | <tr class='item <?php echo(($c = ! $c) ? ' odd' : '') ?>'> |
247 | 247 | <td><?php $payment->e('PAY_gateway') ?></td> |
248 | 248 | <td><?php echo esc_html($payment->timestamp('D M j, Y')); ?></td> |
@@ -251,23 +251,23 @@ discard block |
||
251 | 251 | <td><?php $payment->e_pretty_status() ?></td> |
252 | 252 | <td class='item_r'> |
253 | 253 | <?php echo wp_kses( |
254 | - EEH_Template::format_currency($payment->amount()), |
|
255 | - AllowedTags::getAllowedTags() |
|
256 | - ); ?> |
|
254 | + EEH_Template::format_currency($payment->amount()), |
|
255 | + AllowedTags::getAllowedTags() |
|
256 | + ); ?> |
|
257 | 257 | </td> |
258 | 258 | </tr> |
259 | 259 | <?php } |
260 | - } else { |
|
261 | - ?> |
|
260 | + } else { |
|
261 | + ?> |
|
262 | 262 | <tr class='item'> |
263 | 263 | <td class='aln-cntr' colspan=6> |
264 | 264 | <?php esc_html_e( |
265 | - "No approved payments have been received", |
|
266 | - 'event_espresso' |
|
267 | - ) ?></td> |
|
265 | + "No approved payments have been received", |
|
266 | + 'event_espresso' |
|
267 | + ) ?></td> |
|
268 | 268 | </tr> |
269 | 269 | <?php } |
270 | - ?> |
|
270 | + ?> |
|
271 | 271 | </tbody> |
272 | 272 | <tfoot> |
273 | 273 | <tr class='total_tr'> |
@@ -275,9 +275,9 @@ discard block |
||
275 | 275 | <td class="item_r"><?php esc_html_e('Total Paid', 'event_espresso') ?></td> |
276 | 276 | <td class="item_r"> |
277 | 277 | <?php echo wp_kses( |
278 | - EEH_Template::format_currency($amount_pd), |
|
279 | - AllowedTags::getAllowedTags() |
|
280 | - ); ?> |
|
278 | + EEH_Template::format_currency($amount_pd), |
|
279 | + AllowedTags::getAllowedTags() |
|
280 | + ); ?> |
|
281 | 281 | </td> |
282 | 282 | </tr> |
283 | 283 | <tr class="total_tr"> |
@@ -285,9 +285,9 @@ discard block |
||
285 | 285 | <td class="total" id="total_currency"><?php esc_html_e('Amount Owed', 'event_espresso'); ?></td> |
286 | 286 | <td class="total"> |
287 | 287 | <?php echo wp_kses( |
288 | - EEH_Template::format_currency($total_cost - $amount_pd), |
|
289 | - AllowedTags::getAllowedTags() |
|
290 | - ); ?> |
|
288 | + EEH_Template::format_currency($total_cost - $amount_pd), |
|
289 | + AllowedTags::getAllowedTags() |
|
290 | + ); ?> |
|
291 | 291 | </td> |
292 | 292 | </tr> |
293 | 293 | </tfoot> |
@@ -64,10 +64,10 @@ discard block |
||
64 | 64 | <h3 class="section-title event-name"> |
65 | 65 | <img class="icon" src="<?php echo EE_IMAGES_URL . 'calendar_year-24x24.png'; ?>"> |
66 | 66 | <?php |
67 | - esc_html_e( |
|
68 | - "Event Name:", |
|
69 | - "event_espresso" |
|
70 | - ) ?> |
|
67 | + esc_html_e( |
|
68 | + "Event Name:", |
|
69 | + "event_espresso" |
|
70 | + ) ?> |
|
71 | 71 | <span class="plain-text"><?php echo wp_kses($event->name(), AllowedTags::getAllowedTags()); ?></span> |
72 | 72 | <span class="small-text link"> |
73 | 73 | [ <a href='<?php echo esc_url_raw($event->get_permalink()) ?>'><?php esc_html_e('view', 'event_espresso'); ?></a> ] |
@@ -78,14 +78,14 @@ discard block |
||
78 | 78 | <?php } ?> |
79 | 79 | <ul class="tickets-per-event"> |
80 | 80 | <?php |
81 | - foreach ($ticket_line_items_per_event[ $event_id ] as $line_item_id => $line_item) { |
|
82 | - $ticket = $line_item->ticket(); |
|
83 | - $taxable_html = $ticket->taxable() |
|
84 | - ? '*' |
|
85 | - : ''; |
|
86 | - $subitems = $line_item->children(); |
|
87 | - $ticket_uses = $ticket->get_pretty('TKT_uses', esc_html__("any", "event_espresso")); |
|
88 | - ?> |
|
81 | + foreach ($ticket_line_items_per_event[ $event_id ] as $line_item_id => $line_item) { |
|
82 | + $ticket = $line_item->ticket(); |
|
83 | + $taxable_html = $ticket->taxable() |
|
84 | + ? '*' |
|
85 | + : ''; |
|
86 | + $subitems = $line_item->children(); |
|
87 | + $ticket_uses = $ticket->get_pretty('TKT_uses', esc_html__("any", "event_espresso")); |
|
88 | + ?> |
|
89 | 89 | <li class="event-ticket"> |
90 | 90 | <div class="ticket-details"> |
91 | 91 | <table class="invoice-amount"> |
@@ -94,10 +94,10 @@ discard block |
||
94 | 94 | <th class="name-column"><?php esc_html_e("Ticket", "event_espresso"); ?></th> |
95 | 95 | <th colspan="2" class="desc-column"> |
96 | 96 | <?php |
97 | - esc_html_e( |
|
98 | - "Description", |
|
99 | - "event_espresso" |
|
100 | - ); ?></th> |
|
97 | + esc_html_e( |
|
98 | + "Description", |
|
99 | + "event_espresso" |
|
100 | + ); ?></th> |
|
101 | 101 | <th class="number-column item_c"><?php esc_html_e("Quantity", "event_espresso"); ?></th> |
102 | 102 | <th class="number-column item_c"><?php esc_html_e("Price", "event_espresso"); ?></th> |
103 | 103 | <th class="number-column item_r"><?php esc_html_e("Total", "event_espresso"); ?></th> |
@@ -105,20 +105,20 @@ discard block |
||
105 | 105 | </thead> |
106 | 106 | <tbody> |
107 | 107 | <?php |
108 | - if (count($subitems) < 2) { ?> |
|
108 | + if (count($subitems) < 2) { ?> |
|
109 | 109 | <tr class="item"> |
110 | 110 | <td><?php echo esc_html($line_item->name() . $taxable_html); ?></td> |
111 | 111 | <td colspan="2"> |
112 | 112 | <?php echo esc_html($line_item->desc()); ?> |
113 | 113 | <p class="ticket-note"> |
114 | 114 | <?php |
115 | - echo sprintf( |
|
116 | - esc_html__( |
|
117 | - 'This ticket can be used once at %s of the dates/times below.', |
|
118 | - 'event_espresso' |
|
119 | - ), |
|
120 | - $ticket_uses |
|
121 | - ); ?> |
|
115 | + echo sprintf( |
|
116 | + esc_html__( |
|
117 | + 'This ticket can be used once at %s of the dates/times below.', |
|
118 | + 'event_espresso' |
|
119 | + ), |
|
120 | + $ticket_uses |
|
121 | + ); ?> |
|
122 | 122 | </p> |
123 | 123 | </td> |
124 | 124 | <td class="item_c"><?php echo esc_html($line_item->quantity()); ?></td> |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | <td class="item_r"><?php echo wp_kses($line_item->total_no_code(), AllowedTags::getAllowedTags()); ?></td> |
127 | 127 | </tr> |
128 | 128 | <?php |
129 | - } else { ?> |
|
129 | + } else { ?> |
|
130 | 130 | <tr class="item"> |
131 | 131 | <td class="aln-left"> |
132 | 132 | <?php echo esc_html($line_item->name() . $taxable_html); ?> |
@@ -134,13 +134,13 @@ discard block |
||
134 | 134 | <td colspan="2"><?php echo esc_html($line_item->desc()); ?> |
135 | 135 | <p class="ticket-note"> |
136 | 136 | <?php |
137 | - echo sprintf( |
|
138 | - esc_html__( |
|
139 | - 'This ticket can be used once at %s of the dates/times below.', |
|
140 | - 'event_espresso' |
|
141 | - ), |
|
142 | - $ticket_uses |
|
143 | - ); ?> |
|
137 | + echo sprintf( |
|
138 | + esc_html__( |
|
139 | + 'This ticket can be used once at %s of the dates/times below.', |
|
140 | + 'event_espresso' |
|
141 | + ), |
|
142 | + $ticket_uses |
|
143 | + ); ?> |
|
144 | 144 | </p> |
145 | 145 | </td> |
146 | 146 | <td class="item_c"> |
@@ -154,8 +154,8 @@ discard block |
||
154 | 154 | </td> |
155 | 155 | </tr> |
156 | 156 | <?php |
157 | - foreach ($subitems as $sub_line_item) { |
|
158 | - $is_percent = $sub_line_item->is_percent(); ?> |
|
157 | + foreach ($subitems as $sub_line_item) { |
|
158 | + $is_percent = $sub_line_item->is_percent(); ?> |
|
159 | 159 | <tr class="subitem-row"> |
160 | 160 | <td class="subitem"> |
161 | 161 | <?php echo esc_html($sub_line_item->name()); ?> |
@@ -167,21 +167,21 @@ discard block |
||
167 | 167 | </td> |
168 | 168 | <td class="item_c"> |
169 | 169 | <?php echo wp_kses( |
170 | - $is_percent |
|
171 | - ? $sub_line_item->percent() . "%" |
|
172 | - : $sub_line_item->unit_price_no_code(), |
|
173 | - AllowedTags::getAllowedTags() |
|
174 | - ); ?> |
|
170 | + $is_percent |
|
171 | + ? $sub_line_item->percent() . "%" |
|
172 | + : $sub_line_item->unit_price_no_code(), |
|
173 | + AllowedTags::getAllowedTags() |
|
174 | + ); ?> |
|
175 | 175 | </td> |
176 | 176 | <td class="item_r"> |
177 | 177 | <?php echo wp_kses( |
178 | - $sub_line_item->total_no_code(), |
|
179 | - AllowedTags::getAllowedTags() |
|
180 | - ); ?> |
|
178 | + $sub_line_item->total_no_code(), |
|
179 | + AllowedTags::getAllowedTags() |
|
180 | + ); ?> |
|
181 | 181 | </td> |
182 | 182 | </tr> |
183 | 183 | <?php |
184 | - } ?> |
|
184 | + } ?> |
|
185 | 185 | <tr class="total_tr odd"> |
186 | 186 | <td colspan="4"></td> |
187 | 187 | <td class="total" nowrap="nowrap"> |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | </td> |
193 | 193 | </tr> |
194 | 194 | <?php |
195 | - } ?> |
|
195 | + } ?> |
|
196 | 196 | </tbody> |
197 | 197 | </table> |
198 | 198 | |
@@ -203,56 +203,56 @@ discard block |
||
203 | 203 | <h4 class="sub-section-title no-bottom-margin"> |
204 | 204 | <img class="icon" src="<?php echo esc_url_raw(EE_IMAGES_URL . 'clock-16x16.png'); ?>"> |
205 | 205 | <?php |
206 | - echo _n( |
|
207 | - "Date/Time:", |
|
208 | - "Dates/Times:", |
|
209 | - count($ticket->datetimes()), |
|
210 | - "event_espresso" |
|
211 | - ); ?></h4> |
|
206 | + echo _n( |
|
207 | + "Date/Time:", |
|
208 | + "Dates/Times:", |
|
209 | + count($ticket->datetimes()), |
|
210 | + "event_espresso" |
|
211 | + ); ?></h4> |
|
212 | 212 | <ul class="event-dates"> |
213 | 213 | <?php |
214 | - foreach ($ticket->datetimes_ordered() as $datetime) { |
|
215 | - /* @var $datetime EE_Datetime */ ?> |
|
214 | + foreach ($ticket->datetimes_ordered() as $datetime) { |
|
215 | + /* @var $datetime EE_Datetime */ ?> |
|
216 | 216 | <li><?php |
217 | - echo wp_kses( |
|
218 | - $datetime->name() |
|
219 | - ? '<b>' . esc_html($datetime->name()) . ' </b>' |
|
220 | - : '', |
|
221 | - AllowedTags::getAllowedTags() |
|
222 | - ); |
|
223 | - echo sprintf( |
|
224 | - esc_html__("%s - %s (%s)", "event_espresso"), |
|
225 | - $datetime->start_date_and_time(), |
|
226 | - $datetime->end_date_and_time(), |
|
227 | - $datetime->get_timezone() |
|
228 | - ); |
|
229 | - echo wp_kses( |
|
230 | - $datetime->description() |
|
231 | - ? '<p class="ticket-note">' . $datetime->description() . '</p>' |
|
232 | - : '', |
|
233 | - AllowedTags::getAllowedTags() |
|
234 | - ); ?> |
|
217 | + echo wp_kses( |
|
218 | + $datetime->name() |
|
219 | + ? '<b>' . esc_html($datetime->name()) . ' </b>' |
|
220 | + : '', |
|
221 | + AllowedTags::getAllowedTags() |
|
222 | + ); |
|
223 | + echo sprintf( |
|
224 | + esc_html__("%s - %s (%s)", "event_espresso"), |
|
225 | + $datetime->start_date_and_time(), |
|
226 | + $datetime->end_date_and_time(), |
|
227 | + $datetime->get_timezone() |
|
228 | + ); |
|
229 | + echo wp_kses( |
|
230 | + $datetime->description() |
|
231 | + ? '<p class="ticket-note">' . $datetime->description() . '</p>' |
|
232 | + : '', |
|
233 | + AllowedTags::getAllowedTags() |
|
234 | + ); ?> |
|
235 | 235 | </li> |
236 | 236 | <?php |
237 | - } ?> |
|
237 | + } ?> |
|
238 | 238 | </ul> |
239 | 239 | </div> |
240 | 240 | <?php |
241 | - if ($event->venues()) { ?> |
|
241 | + if ($event->venues()) { ?> |
|
242 | 242 | <div class="ticket-place-details"> |
243 | 243 | <h4 class="sub-section-title no-bottom-margin"> |
244 | 244 | <img class="icon" src="<?php |
245 | - echo esc_url_raw(EE_IMAGES_URL . 'location-pin-16x16.png'); ?>"> |
|
245 | + echo esc_url_raw(EE_IMAGES_URL . 'location-pin-16x16.png'); ?>"> |
|
246 | 246 | <?php |
247 | - echo _n( |
|
248 | - "Venue:", |
|
249 | - "Venues:", |
|
250 | - count($event->venues()), |
|
251 | - "event_espresso" |
|
252 | - ); ?></h4> |
|
247 | + echo _n( |
|
248 | + "Venue:", |
|
249 | + "Venues:", |
|
250 | + count($event->venues()), |
|
251 | + "event_espresso" |
|
252 | + ); ?></h4> |
|
253 | 253 | <ul class="event-venues"> |
254 | 254 | <?php |
255 | - foreach ($event->venues() as $venue) { ?> |
|
255 | + foreach ($event->venues() as $venue) { ?> |
|
256 | 256 | <li><?php echo esc_html($venue->name()) ?> |
257 | 257 | <span class="small-text"> |
258 | 258 | [ |
@@ -263,18 +263,18 @@ discard block |
||
263 | 263 | </span> |
264 | 264 | </li> |
265 | 265 | <?php |
266 | - } ?> |
|
266 | + } ?> |
|
267 | 267 | </ul> |
268 | 268 | </div> |
269 | 269 | <?php |
270 | - } ?> |
|
270 | + } ?> |
|
271 | 271 | </div> |
272 | 272 | <div class="ticket-registrations-area"> |
273 | 273 | <h4 class="sub-section-title"> |
274 | 274 | <img class="icon" src="<?php |
275 | - echo esc_url_raw(EE_IMAGES_URL . 'users-16x16.png'); ?>"> |
|
275 | + echo esc_url_raw(EE_IMAGES_URL . 'users-16x16.png'); ?>"> |
|
276 | 276 | <?php |
277 | - echo esc_html__("Registration Details", "event_espresso"); ?> |
|
277 | + echo esc_html__("Registration Details", "event_espresso"); ?> |
|
278 | 278 | <span class="small-text link">[ |
279 | 279 | <a class="print_button noPrint" href="<?php echo esc_url_raw($edit_reg_info_url); ?>"> |
280 | 280 | <?php esc_html_e('edit', 'event_espresso'); ?> |
@@ -284,12 +284,12 @@ discard block |
||
284 | 284 | </h4> |
285 | 285 | <ul class="ticket-registrations-list"> |
286 | 286 | <?php |
287 | - foreach ($registrations_per_line_item[ $line_item_id ] as $registration) { |
|
288 | - /* @var $registration EE_Registration */ |
|
289 | - $attendee = $registration->attendee(); |
|
290 | - $answers = $registration->answers( |
|
291 | - ['order_by' => ['Question.Question_Group_Question.QGQ_order' => 'ASC']] |
|
292 | - ); ?> |
|
287 | + foreach ($registrations_per_line_item[ $line_item_id ] as $registration) { |
|
288 | + /* @var $registration EE_Registration */ |
|
289 | + $attendee = $registration->attendee(); |
|
290 | + $answers = $registration->answers( |
|
291 | + ['order_by' => ['Question.Question_Group_Question.QGQ_order' => 'ASC']] |
|
292 | + ); ?> |
|
293 | 293 | <li class="ticket-registration"> |
294 | 294 | <table class="registration-details"> |
295 | 295 | <tr class="odd"> |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | </td> |
305 | 305 | </tr> |
306 | 306 | <?php |
307 | - foreach ($event->question_groups() as $question_group) { ?> |
|
307 | + foreach ($event->question_groups() as $question_group) { ?> |
|
308 | 308 | <tr> |
309 | 309 | <th> |
310 | 310 | <?php $question_group->e('QSG_name'); ?> |
@@ -312,12 +312,12 @@ discard block |
||
312 | 312 | <td></td> |
313 | 313 | </tr> |
314 | 314 | <?php $has_personal_info = false; |
315 | - foreach ($question_group->questions() as $question) { |
|
316 | - if (in_array($question->system_ID(), $questions_to_skip)) { |
|
317 | - $has_personal_info = true; |
|
318 | - continue; |
|
319 | - } |
|
320 | - ?> |
|
315 | + foreach ($question_group->questions() as $question) { |
|
316 | + if (in_array($question->system_ID(), $questions_to_skip)) { |
|
317 | + $has_personal_info = true; |
|
318 | + continue; |
|
319 | + } |
|
320 | + ?> |
|
321 | 321 | <tr> |
322 | 322 | <th> |
323 | 323 | <?php echo wp_kses($question->display_text(), AllowedTags::getAllowedTags()); ?> |
@@ -327,26 +327,26 @@ discard block |
||
327 | 327 | </td> |
328 | 328 | </tr> |
329 | 329 | <?php } |
330 | - if ($has_personal_info) { ?> |
|
330 | + if ($has_personal_info) { ?> |
|
331 | 331 | <tr> |
332 | 332 | <th><?php esc_html_e('Attendee', 'event_espresso'); ?></th> |
333 | 333 | <td> |
334 | 334 | <?php |
335 | - echo sprintf( |
|
336 | - esc_html__('%s (%s)', "event_espresso"), |
|
337 | - esc_html($attendee->full_name()), |
|
338 | - sanitize_email($attendee->email()) |
|
339 | - ) ?> |
|
335 | + echo sprintf( |
|
336 | + esc_html__('%s (%s)', "event_espresso"), |
|
337 | + esc_html($attendee->full_name()), |
|
338 | + sanitize_email($attendee->email()) |
|
339 | + ) ?> |
|
340 | 340 | </td> |
341 | 341 | </tr> |
342 | 342 | <?php |
343 | - } |
|
344 | - } |
|
345 | - ?> |
|
343 | + } |
|
344 | + } |
|
345 | + ?> |
|
346 | 346 | </table> |
347 | 347 | </li> |
348 | 348 | <?php |
349 | - } ?> |
|
349 | + } ?> |
|
350 | 350 | </ul> |
351 | 351 | </div> |
352 | 352 | </div> |
@@ -390,10 +390,10 @@ discard block |
||
390 | 390 | <div class="grand-total-dv"> |
391 | 391 | <h2 class="grand-total"> |
392 | 392 | <?php |
393 | - printf( |
|
394 | - esc_html__("Grand Total: %s", "event_espresso"), |
|
395 | - EEH_Template::format_currency($total_cost) |
|
396 | - ); ?> |
|
393 | + printf( |
|
394 | + esc_html__("Grand Total: %s", "event_espresso"), |
|
395 | + EEH_Template::format_currency($total_cost) |
|
396 | + ); ?> |
|
397 | 397 | </h2> |
398 | 398 | </div> |
399 | 399 | <div class="payment-dv"> |
@@ -412,13 +412,13 @@ discard block |
||
412 | 412 | </thead> |
413 | 413 | <tbody> |
414 | 414 | <?php |
415 | - $c = false; |
|
416 | - if (! empty($payments)) { |
|
417 | - foreach ($payments as $payment) { |
|
418 | - /* @var $payment EE_Payment */ ?> |
|
415 | + $c = false; |
|
416 | + if (! empty($payments)) { |
|
417 | + foreach ($payments as $payment) { |
|
418 | + /* @var $payment EE_Payment */ ?> |
|
419 | 419 | <tr class='item <?php echo(($c = ! $c) |
420 | - ? ' odd' |
|
421 | - : '') ?>'> |
|
420 | + ? ' odd' |
|
421 | + : '') ?>'> |
|
422 | 422 | <td><?php $payment->e('PAY_gateway') ?></td> |
423 | 423 | <td><?php echo esc_html($payment->timestamp()); ?></td> |
424 | 424 | <td><?php $payment->e('PAY_txn_id_chq_nmbr') ?></td> |
@@ -427,14 +427,14 @@ discard block |
||
427 | 427 | <td class='item_r'><?php echo wp_kses($payment->amount_no_code(), AllowedTags::getAllowedTags()); ?></td> |
428 | 428 | </tr> |
429 | 429 | <?php } |
430 | - } else { ?> |
|
430 | + } else { ?> |
|
431 | 431 | <tr class='item'> |
432 | 432 | <td class='aln-cntr' colspan="6"> |
433 | 433 | <?php |
434 | - esc_html_e( |
|
435 | - "No approved payments have been received.", |
|
436 | - 'event_espresso' |
|
437 | - ) ?> |
|
434 | + esc_html_e( |
|
435 | + "No approved payments have been received.", |
|
436 | + 'event_espresso' |
|
437 | + ) ?> |
|
438 | 438 | </td> |
439 | 439 | </tr> |
440 | 440 | <?php } ?> |
@@ -454,9 +454,9 @@ discard block |
||
454 | 454 | <td class="item_r"><?php esc_html_e('Total Paid', 'event_espresso') ?></td> |
455 | 455 | <td class="item_r"> |
456 | 456 | <?php echo wp_kses( |
457 | - EEH_Template::format_currency($amount_pd, false, false), |
|
458 | - AllowedTags::getAllowedTags() |
|
459 | - ); ?> |
|
457 | + EEH_Template::format_currency($amount_pd, false, false), |
|
458 | + AllowedTags::getAllowedTags() |
|
459 | + ); ?> |
|
460 | 460 | </td> |
461 | 461 | </tr> |
462 | 462 | <tr class="total_tr odd"> |
@@ -464,9 +464,9 @@ discard block |
||
464 | 464 | <td class="total" id="total_currency"><?php esc_html_e('Amount Owed:', 'event_espresso'); ?></td> |
465 | 465 | <td class="total"> |
466 | 466 | <?php echo wp_kses( |
467 | - EEH_Template::format_currency($amount_owed), |
|
468 | - AllowedTags::getAllowedTags() |
|
469 | - ); ?> |
|
467 | + EEH_Template::format_currency($amount_owed), |
|
468 | + AllowedTags::getAllowedTags() |
|
469 | + ); ?> |
|
470 | 470 | </td> |
471 | 471 | </tr> |
472 | 472 | </tfoot> |
@@ -478,7 +478,7 @@ discard block |
||
478 | 478 | <?php if ($venues_for_events) { ?> |
479 | 479 | <h2> |
480 | 480 | <?php |
481 | - echo _n("Venue Details:", "Venues Details:", count($venues_for_events), "event_espresso"); ?> |
|
481 | + echo _n("Venue Details:", "Venues Details:", count($venues_for_events), "event_espresso"); ?> |
|
482 | 482 | </h2> |
483 | 483 | <table class="venue-list"> |
484 | 484 | <?php foreach ($venues_for_events as $venue) { ?> |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | <div class="events"> |
63 | 63 | <?php foreach ($events_for_txn as $event_id => $event) { ?> |
64 | 64 | <h3 class="section-title event-name"> |
65 | - <img class="icon" src="<?php echo EE_IMAGES_URL . 'calendar_year-24x24.png'; ?>"> |
|
65 | + <img class="icon" src="<?php echo EE_IMAGES_URL.'calendar_year-24x24.png'; ?>"> |
|
66 | 66 | <?php |
67 | 67 | esc_html_e( |
68 | 68 | "Event Name:", |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | <?php } ?> |
79 | 79 | <ul class="tickets-per-event"> |
80 | 80 | <?php |
81 | - foreach ($ticket_line_items_per_event[ $event_id ] as $line_item_id => $line_item) { |
|
81 | + foreach ($ticket_line_items_per_event[$event_id] as $line_item_id => $line_item) { |
|
82 | 82 | $ticket = $line_item->ticket(); |
83 | 83 | $taxable_html = $ticket->taxable() |
84 | 84 | ? '*' |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | <?php |
108 | 108 | if (count($subitems) < 2) { ?> |
109 | 109 | <tr class="item"> |
110 | - <td><?php echo esc_html($line_item->name() . $taxable_html); ?></td> |
|
110 | + <td><?php echo esc_html($line_item->name().$taxable_html); ?></td> |
|
111 | 111 | <td colspan="2"> |
112 | 112 | <?php echo esc_html($line_item->desc()); ?> |
113 | 113 | <p class="ticket-note"> |
@@ -123,13 +123,13 @@ discard block |
||
123 | 123 | </td> |
124 | 124 | <td class="item_c"><?php echo esc_html($line_item->quantity()); ?></td> |
125 | 125 | <td class="item_c"><?php echo wp_kses($line_item->unit_price_no_code(), AllowedTags::getAllowedTags()); ?></td> |
126 | - <td class="item_r"><?php echo wp_kses($line_item->total_no_code(), AllowedTags::getAllowedTags()); ?></td> |
|
126 | + <td class="item_r"><?php echo wp_kses($line_item->total_no_code(), AllowedTags::getAllowedTags()); ?></td> |
|
127 | 127 | </tr> |
128 | 128 | <?php |
129 | 129 | } else { ?> |
130 | 130 | <tr class="item"> |
131 | 131 | <td class="aln-left"> |
132 | - <?php echo esc_html($line_item->name() . $taxable_html); ?> |
|
132 | + <?php echo esc_html($line_item->name().$taxable_html); ?> |
|
133 | 133 | </td> |
134 | 134 | <td colspan="2"><?php echo esc_html($line_item->desc()); ?> |
135 | 135 | <p class="ticket-note"> |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | <td class="item_c"> |
169 | 169 | <?php echo wp_kses( |
170 | 170 | $is_percent |
171 | - ? $sub_line_item->percent() . "%" |
|
171 | + ? $sub_line_item->percent()."%" |
|
172 | 172 | : $sub_line_item->unit_price_no_code(), |
173 | 173 | AllowedTags::getAllowedTags() |
174 | 174 | ); ?> |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | <div class="ticket-time-and-place-details"> |
202 | 202 | <div class="ticket-time-details"> |
203 | 203 | <h4 class="sub-section-title no-bottom-margin"> |
204 | - <img class="icon" src="<?php echo esc_url_raw(EE_IMAGES_URL . 'clock-16x16.png'); ?>"> |
|
204 | + <img class="icon" src="<?php echo esc_url_raw(EE_IMAGES_URL.'clock-16x16.png'); ?>"> |
|
205 | 205 | <?php |
206 | 206 | echo _n( |
207 | 207 | "Date/Time:", |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | <li><?php |
217 | 217 | echo wp_kses( |
218 | 218 | $datetime->name() |
219 | - ? '<b>' . esc_html($datetime->name()) . ' </b>' |
|
219 | + ? '<b>'.esc_html($datetime->name()).' </b>' |
|
220 | 220 | : '', |
221 | 221 | AllowedTags::getAllowedTags() |
222 | 222 | ); |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | ); |
229 | 229 | echo wp_kses( |
230 | 230 | $datetime->description() |
231 | - ? '<p class="ticket-note">' . $datetime->description() . '</p>' |
|
231 | + ? '<p class="ticket-note">'.$datetime->description().'</p>' |
|
232 | 232 | : '', |
233 | 233 | AllowedTags::getAllowedTags() |
234 | 234 | ); ?> |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | <div class="ticket-place-details"> |
243 | 243 | <h4 class="sub-section-title no-bottom-margin"> |
244 | 244 | <img class="icon" src="<?php |
245 | - echo esc_url_raw(EE_IMAGES_URL . 'location-pin-16x16.png'); ?>"> |
|
245 | + echo esc_url_raw(EE_IMAGES_URL.'location-pin-16x16.png'); ?>"> |
|
246 | 246 | <?php |
247 | 247 | echo _n( |
248 | 248 | "Venue:", |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | <div class="ticket-registrations-area"> |
273 | 273 | <h4 class="sub-section-title"> |
274 | 274 | <img class="icon" src="<?php |
275 | - echo esc_url_raw(EE_IMAGES_URL . 'users-16x16.png'); ?>"> |
|
275 | + echo esc_url_raw(EE_IMAGES_URL.'users-16x16.png'); ?>"> |
|
276 | 276 | <?php |
277 | 277 | echo esc_html__("Registration Details", "event_espresso"); ?> |
278 | 278 | <span class="small-text link">[ |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | </h4> |
285 | 285 | <ul class="ticket-registrations-list"> |
286 | 286 | <?php |
287 | - foreach ($registrations_per_line_item[ $line_item_id ] as $registration) { |
|
287 | + foreach ($registrations_per_line_item[$line_item_id] as $registration) { |
|
288 | 288 | /* @var $registration EE_Registration */ |
289 | 289 | $attendee = $registration->attendee(); |
290 | 290 | $answers = $registration->answers( |
@@ -413,7 +413,7 @@ discard block |
||
413 | 413 | <tbody> |
414 | 414 | <?php |
415 | 415 | $c = false; |
416 | - if (! empty($payments)) { |
|
416 | + if ( ! empty($payments)) { |
|
417 | 417 | foreach ($payments as $payment) { |
418 | 418 | /* @var $payment EE_Payment */ ?> |
419 | 419 | <tr class='item <?php echo(($c = ! $c) |
@@ -14,400 +14,400 @@ |
||
14 | 14 | */ |
15 | 15 | class EE_SPCO_JSON_Response |
16 | 16 | { |
17 | - /** |
|
18 | - * @var string |
|
19 | - */ |
|
20 | - protected $_errors = ''; |
|
21 | - |
|
22 | - /** |
|
23 | - * @var string |
|
24 | - */ |
|
25 | - protected $_unexpected_errors = ''; |
|
26 | - |
|
27 | - /** |
|
28 | - * @var string |
|
29 | - */ |
|
30 | - protected $_attention = ''; |
|
31 | - |
|
32 | - /** |
|
33 | - * @var string |
|
34 | - */ |
|
35 | - protected $_success = ''; |
|
36 | - |
|
37 | - /** |
|
38 | - * @var string |
|
39 | - */ |
|
40 | - protected $_plz_select_method_of_payment = ''; |
|
41 | - |
|
42 | - /** |
|
43 | - * @var string |
|
44 | - */ |
|
45 | - protected $_redirect_url = ''; |
|
46 | - |
|
47 | - /** |
|
48 | - * @var string |
|
49 | - */ |
|
50 | - protected $_registration_time_limit = ''; |
|
51 | - |
|
52 | - /** |
|
53 | - * @var string |
|
54 | - */ |
|
55 | - protected $_redirect_form = ''; |
|
56 | - |
|
57 | - /** |
|
58 | - * @var string |
|
59 | - */ |
|
60 | - protected $_reg_step_html = ''; |
|
61 | - |
|
62 | - /** |
|
63 | - * @var string |
|
64 | - */ |
|
65 | - protected $_method_of_payment = ''; |
|
66 | - |
|
67 | - /** |
|
68 | - * @var float |
|
69 | - */ |
|
70 | - protected $_payment_amount; |
|
71 | - |
|
72 | - /** |
|
73 | - * @var array |
|
74 | - */ |
|
75 | - protected $_return_data = array(); |
|
76 | - |
|
77 | - |
|
78 | - /** |
|
79 | - * @var array |
|
80 | - */ |
|
81 | - protected $_validation_rules = array(); |
|
82 | - |
|
83 | - |
|
84 | - /** |
|
85 | - * class constructor |
|
86 | - */ |
|
87 | - public function __construct() |
|
88 | - { |
|
89 | - } |
|
90 | - |
|
91 | - |
|
92 | - /** |
|
93 | - * __toString |
|
94 | - * |
|
95 | - * allows you to simply echo or print an EE_SPCO_JSON_Response object to produce a JSON encoded string |
|
96 | - * |
|
97 | - * @access public |
|
98 | - * @return string |
|
99 | - */ |
|
100 | - public function __toString() |
|
101 | - { |
|
102 | - $JSON_response = array(); |
|
103 | - // grab notices |
|
104 | - $notices = EE_Error::get_notices(false); |
|
105 | - $this->set_attention(isset($notices['attention']) ? $notices['attention'] : ''); |
|
106 | - $this->set_errors(isset($notices['errors']) ? $notices['errors'] : ''); |
|
107 | - $this->set_success(isset($notices['success']) ? $notices['success'] : ''); |
|
108 | - // add notices to JSON response, but only if they exist |
|
109 | - if ($this->attention()) { |
|
110 | - $JSON_response['attention'] = $this->attention(); |
|
111 | - } |
|
112 | - if ($this->errors()) { |
|
113 | - $JSON_response['errors'] = $this->errors(); |
|
114 | - } |
|
115 | - if ($this->unexpected_errors()) { |
|
116 | - $JSON_response['unexpected_errors'] = $this->unexpected_errors(); |
|
117 | - } |
|
118 | - if ($this->success()) { |
|
119 | - $JSON_response['success'] = $this->success(); |
|
120 | - } |
|
121 | - // but if NO notices are set... at least set the "success" as a key so that the JS knows everything worked |
|
122 | - if (! isset($JSON_response['attention']) && ! isset($JSON_response['errors']) && ! isset($JSON_response['success'])) { |
|
123 | - $JSON_response['success'] = null; |
|
124 | - } |
|
125 | - // set redirect_url, IF it exists |
|
126 | - if ($this->redirect_url()) { |
|
127 | - $JSON_response['redirect_url'] = $this->redirect_url(); |
|
128 | - } |
|
129 | - // set registration_time_limit, IF it exists |
|
130 | - if ($this->registration_time_limit()) { |
|
131 | - $JSON_response['registration_time_limit'] = $this->registration_time_limit(); |
|
132 | - } |
|
133 | - // set payment_amount, IF it exists |
|
134 | - if ($this->payment_amount() !== null) { |
|
135 | - $JSON_response['payment_amount'] = $this->payment_amount(); |
|
136 | - } |
|
137 | - // grab generic return data |
|
138 | - $return_data = $this->return_data(); |
|
139 | - // add billing form validation rules |
|
140 | - if ($this->validation_rules()) { |
|
141 | - $return_data['validation_rules'] = $this->validation_rules(); |
|
142 | - } |
|
143 | - // set reg_step_html, IF it exists |
|
144 | - if ($this->reg_step_html()) { |
|
145 | - $return_data['reg_step_html'] = $this->reg_step_html(); |
|
146 | - } |
|
147 | - // set method of payment, IF it exists |
|
148 | - if ($this->method_of_payment()) { |
|
149 | - $return_data['method_of_payment'] = $this->method_of_payment(); |
|
150 | - } |
|
151 | - // set "plz_select_method_of_payment" message, IF it exists |
|
152 | - if ($this->plz_select_method_of_payment()) { |
|
153 | - $return_data['plz_select_method_of_payment'] = $this->plz_select_method_of_payment(); |
|
154 | - } |
|
155 | - // set redirect_form, IF it exists |
|
156 | - if ($this->redirect_form()) { |
|
157 | - $return_data['redirect_form'] = $this->redirect_form(); |
|
158 | - } |
|
159 | - // and finally, add return_data array to main JSON response array, IF it contains anything |
|
160 | - // why did we add some of the above properties to the return data array? |
|
161 | - // because it is easier and cleaner in the Javascript to deal with this way |
|
162 | - if (! empty($return_data)) { |
|
163 | - $JSON_response['return_data'] = $return_data; |
|
164 | - } |
|
165 | - // filter final array |
|
166 | - $JSON_response = apply_filters('FHEE__EE_SPCO_JSON_Response___toString__JSON_response', $JSON_response); |
|
167 | - // return encoded array |
|
168 | - return (string) wp_json_encode($JSON_response); |
|
169 | - } |
|
170 | - |
|
171 | - |
|
172 | - /** |
|
173 | - * @param string $attention |
|
174 | - */ |
|
175 | - public function set_attention($attention) |
|
176 | - { |
|
177 | - $this->_attention = $attention; |
|
178 | - } |
|
179 | - |
|
180 | - |
|
181 | - /** |
|
182 | - * @return string |
|
183 | - */ |
|
184 | - public function attention() |
|
185 | - { |
|
186 | - return $this->_attention; |
|
187 | - } |
|
188 | - |
|
189 | - |
|
190 | - /** |
|
191 | - * @param string $errors |
|
192 | - */ |
|
193 | - public function set_errors($errors) |
|
194 | - { |
|
195 | - $this->_errors = $errors; |
|
196 | - } |
|
197 | - |
|
198 | - |
|
199 | - /** |
|
200 | - * @return string |
|
201 | - */ |
|
202 | - public function errors() |
|
203 | - { |
|
204 | - return $this->_errors; |
|
205 | - } |
|
206 | - |
|
207 | - |
|
208 | - /** |
|
209 | - * @return string |
|
210 | - */ |
|
211 | - public function unexpected_errors() |
|
212 | - { |
|
213 | - return $this->_unexpected_errors; |
|
214 | - } |
|
215 | - |
|
216 | - |
|
217 | - /** |
|
218 | - * @param string $unexpected_errors |
|
219 | - */ |
|
220 | - public function set_unexpected_errors($unexpected_errors) |
|
221 | - { |
|
222 | - $this->_unexpected_errors = $unexpected_errors; |
|
223 | - } |
|
224 | - |
|
225 | - |
|
226 | - /** |
|
227 | - * @param string $success |
|
228 | - */ |
|
229 | - public function set_success($success) |
|
230 | - { |
|
231 | - $this->_success = $success; |
|
232 | - } |
|
233 | - |
|
234 | - |
|
235 | - /** |
|
236 | - * @return string |
|
237 | - */ |
|
238 | - public function success() |
|
239 | - { |
|
240 | - return $this->_success; |
|
241 | - } |
|
242 | - |
|
243 | - |
|
244 | - /** |
|
245 | - * @param string $method_of_payment |
|
246 | - */ |
|
247 | - public function set_method_of_payment($method_of_payment) |
|
248 | - { |
|
249 | - $this->_method_of_payment = $method_of_payment; |
|
250 | - } |
|
251 | - |
|
252 | - |
|
253 | - /** |
|
254 | - * @return string |
|
255 | - */ |
|
256 | - public function method_of_payment() |
|
257 | - { |
|
258 | - return $this->_method_of_payment; |
|
259 | - } |
|
260 | - |
|
261 | - |
|
262 | - /** |
|
263 | - * @return float |
|
264 | - */ |
|
265 | - public function payment_amount() |
|
266 | - { |
|
267 | - return $this->_payment_amount; |
|
268 | - } |
|
269 | - |
|
270 | - |
|
271 | - /** |
|
272 | - * @param float $payment_amount |
|
273 | - * @throws EE_Error |
|
274 | - */ |
|
275 | - public function set_payment_amount($payment_amount) |
|
276 | - { |
|
277 | - $this->_payment_amount = (float) $payment_amount; |
|
278 | - } |
|
279 | - |
|
280 | - |
|
281 | - /** |
|
282 | - * @param string $next_step_html |
|
283 | - */ |
|
284 | - public function set_reg_step_html($next_step_html) |
|
285 | - { |
|
286 | - $this->_reg_step_html = $next_step_html; |
|
287 | - } |
|
288 | - |
|
289 | - |
|
290 | - /** |
|
291 | - * @return string |
|
292 | - */ |
|
293 | - public function reg_step_html() |
|
294 | - { |
|
295 | - return $this->_reg_step_html; |
|
296 | - } |
|
297 | - |
|
298 | - |
|
299 | - /** |
|
300 | - * @param string $redirect_form |
|
301 | - */ |
|
302 | - public function set_redirect_form($redirect_form) |
|
303 | - { |
|
304 | - $this->_redirect_form = $redirect_form; |
|
305 | - } |
|
306 | - |
|
307 | - |
|
308 | - /** |
|
309 | - * @return string |
|
310 | - */ |
|
311 | - public function redirect_form() |
|
312 | - { |
|
313 | - return ! empty($this->_redirect_form) ? $this->_redirect_form : false; |
|
314 | - } |
|
315 | - |
|
316 | - |
|
317 | - /** |
|
318 | - * @param string $plz_select_method_of_payment |
|
319 | - */ |
|
320 | - public function set_plz_select_method_of_payment($plz_select_method_of_payment) |
|
321 | - { |
|
322 | - $this->_plz_select_method_of_payment = $plz_select_method_of_payment; |
|
323 | - } |
|
324 | - |
|
325 | - |
|
326 | - /** |
|
327 | - * @return string |
|
328 | - */ |
|
329 | - public function plz_select_method_of_payment() |
|
330 | - { |
|
331 | - return $this->_plz_select_method_of_payment; |
|
332 | - } |
|
333 | - |
|
334 | - |
|
335 | - /** |
|
336 | - * @param string $redirect_url |
|
337 | - */ |
|
338 | - public function set_redirect_url($redirect_url) |
|
339 | - { |
|
340 | - $this->_redirect_url = $redirect_url; |
|
341 | - } |
|
342 | - |
|
343 | - |
|
344 | - /** |
|
345 | - * @return string |
|
346 | - */ |
|
347 | - public function redirect_url() |
|
348 | - { |
|
349 | - return $this->_redirect_url; |
|
350 | - } |
|
351 | - |
|
352 | - |
|
353 | - /** |
|
354 | - * @return string |
|
355 | - */ |
|
356 | - public function registration_time_limit() |
|
357 | - { |
|
358 | - return $this->_registration_time_limit; |
|
359 | - } |
|
360 | - |
|
361 | - |
|
362 | - /** |
|
363 | - * @param string $registration_time_limit |
|
364 | - */ |
|
365 | - public function set_registration_time_limit($registration_time_limit) |
|
366 | - { |
|
367 | - $this->_registration_time_limit = $registration_time_limit; |
|
368 | - } |
|
369 | - |
|
370 | - |
|
371 | - /** |
|
372 | - * @param array $return_data |
|
373 | - */ |
|
374 | - public function set_return_data($return_data) |
|
375 | - { |
|
376 | - $this->_return_data = array_merge($this->_return_data, $return_data); |
|
377 | - } |
|
378 | - |
|
379 | - |
|
380 | - /** |
|
381 | - * @return array |
|
382 | - */ |
|
383 | - public function return_data() |
|
384 | - { |
|
385 | - return $this->_return_data; |
|
386 | - } |
|
387 | - |
|
388 | - |
|
389 | - /** |
|
390 | - * @param array $validation_rules |
|
391 | - */ |
|
392 | - public function add_validation_rules(array $validation_rules = array()) |
|
393 | - { |
|
394 | - if (is_array($validation_rules) && ! empty($validation_rules)) { |
|
395 | - $this->_validation_rules = array_merge($this->_validation_rules, $validation_rules); |
|
396 | - } |
|
397 | - } |
|
398 | - |
|
399 | - |
|
400 | - /** |
|
401 | - * @return array | bool |
|
402 | - */ |
|
403 | - public function validation_rules() |
|
404 | - { |
|
405 | - return ! empty($this->_validation_rules) ? $this->_validation_rules : false; |
|
406 | - } |
|
407 | - |
|
408 | - |
|
409 | - public function echoAndExit() |
|
410 | - { |
|
411 | - exit($this->__toString()); |
|
412 | - } |
|
17 | + /** |
|
18 | + * @var string |
|
19 | + */ |
|
20 | + protected $_errors = ''; |
|
21 | + |
|
22 | + /** |
|
23 | + * @var string |
|
24 | + */ |
|
25 | + protected $_unexpected_errors = ''; |
|
26 | + |
|
27 | + /** |
|
28 | + * @var string |
|
29 | + */ |
|
30 | + protected $_attention = ''; |
|
31 | + |
|
32 | + /** |
|
33 | + * @var string |
|
34 | + */ |
|
35 | + protected $_success = ''; |
|
36 | + |
|
37 | + /** |
|
38 | + * @var string |
|
39 | + */ |
|
40 | + protected $_plz_select_method_of_payment = ''; |
|
41 | + |
|
42 | + /** |
|
43 | + * @var string |
|
44 | + */ |
|
45 | + protected $_redirect_url = ''; |
|
46 | + |
|
47 | + /** |
|
48 | + * @var string |
|
49 | + */ |
|
50 | + protected $_registration_time_limit = ''; |
|
51 | + |
|
52 | + /** |
|
53 | + * @var string |
|
54 | + */ |
|
55 | + protected $_redirect_form = ''; |
|
56 | + |
|
57 | + /** |
|
58 | + * @var string |
|
59 | + */ |
|
60 | + protected $_reg_step_html = ''; |
|
61 | + |
|
62 | + /** |
|
63 | + * @var string |
|
64 | + */ |
|
65 | + protected $_method_of_payment = ''; |
|
66 | + |
|
67 | + /** |
|
68 | + * @var float |
|
69 | + */ |
|
70 | + protected $_payment_amount; |
|
71 | + |
|
72 | + /** |
|
73 | + * @var array |
|
74 | + */ |
|
75 | + protected $_return_data = array(); |
|
76 | + |
|
77 | + |
|
78 | + /** |
|
79 | + * @var array |
|
80 | + */ |
|
81 | + protected $_validation_rules = array(); |
|
82 | + |
|
83 | + |
|
84 | + /** |
|
85 | + * class constructor |
|
86 | + */ |
|
87 | + public function __construct() |
|
88 | + { |
|
89 | + } |
|
90 | + |
|
91 | + |
|
92 | + /** |
|
93 | + * __toString |
|
94 | + * |
|
95 | + * allows you to simply echo or print an EE_SPCO_JSON_Response object to produce a JSON encoded string |
|
96 | + * |
|
97 | + * @access public |
|
98 | + * @return string |
|
99 | + */ |
|
100 | + public function __toString() |
|
101 | + { |
|
102 | + $JSON_response = array(); |
|
103 | + // grab notices |
|
104 | + $notices = EE_Error::get_notices(false); |
|
105 | + $this->set_attention(isset($notices['attention']) ? $notices['attention'] : ''); |
|
106 | + $this->set_errors(isset($notices['errors']) ? $notices['errors'] : ''); |
|
107 | + $this->set_success(isset($notices['success']) ? $notices['success'] : ''); |
|
108 | + // add notices to JSON response, but only if they exist |
|
109 | + if ($this->attention()) { |
|
110 | + $JSON_response['attention'] = $this->attention(); |
|
111 | + } |
|
112 | + if ($this->errors()) { |
|
113 | + $JSON_response['errors'] = $this->errors(); |
|
114 | + } |
|
115 | + if ($this->unexpected_errors()) { |
|
116 | + $JSON_response['unexpected_errors'] = $this->unexpected_errors(); |
|
117 | + } |
|
118 | + if ($this->success()) { |
|
119 | + $JSON_response['success'] = $this->success(); |
|
120 | + } |
|
121 | + // but if NO notices are set... at least set the "success" as a key so that the JS knows everything worked |
|
122 | + if (! isset($JSON_response['attention']) && ! isset($JSON_response['errors']) && ! isset($JSON_response['success'])) { |
|
123 | + $JSON_response['success'] = null; |
|
124 | + } |
|
125 | + // set redirect_url, IF it exists |
|
126 | + if ($this->redirect_url()) { |
|
127 | + $JSON_response['redirect_url'] = $this->redirect_url(); |
|
128 | + } |
|
129 | + // set registration_time_limit, IF it exists |
|
130 | + if ($this->registration_time_limit()) { |
|
131 | + $JSON_response['registration_time_limit'] = $this->registration_time_limit(); |
|
132 | + } |
|
133 | + // set payment_amount, IF it exists |
|
134 | + if ($this->payment_amount() !== null) { |
|
135 | + $JSON_response['payment_amount'] = $this->payment_amount(); |
|
136 | + } |
|
137 | + // grab generic return data |
|
138 | + $return_data = $this->return_data(); |
|
139 | + // add billing form validation rules |
|
140 | + if ($this->validation_rules()) { |
|
141 | + $return_data['validation_rules'] = $this->validation_rules(); |
|
142 | + } |
|
143 | + // set reg_step_html, IF it exists |
|
144 | + if ($this->reg_step_html()) { |
|
145 | + $return_data['reg_step_html'] = $this->reg_step_html(); |
|
146 | + } |
|
147 | + // set method of payment, IF it exists |
|
148 | + if ($this->method_of_payment()) { |
|
149 | + $return_data['method_of_payment'] = $this->method_of_payment(); |
|
150 | + } |
|
151 | + // set "plz_select_method_of_payment" message, IF it exists |
|
152 | + if ($this->plz_select_method_of_payment()) { |
|
153 | + $return_data['plz_select_method_of_payment'] = $this->plz_select_method_of_payment(); |
|
154 | + } |
|
155 | + // set redirect_form, IF it exists |
|
156 | + if ($this->redirect_form()) { |
|
157 | + $return_data['redirect_form'] = $this->redirect_form(); |
|
158 | + } |
|
159 | + // and finally, add return_data array to main JSON response array, IF it contains anything |
|
160 | + // why did we add some of the above properties to the return data array? |
|
161 | + // because it is easier and cleaner in the Javascript to deal with this way |
|
162 | + if (! empty($return_data)) { |
|
163 | + $JSON_response['return_data'] = $return_data; |
|
164 | + } |
|
165 | + // filter final array |
|
166 | + $JSON_response = apply_filters('FHEE__EE_SPCO_JSON_Response___toString__JSON_response', $JSON_response); |
|
167 | + // return encoded array |
|
168 | + return (string) wp_json_encode($JSON_response); |
|
169 | + } |
|
170 | + |
|
171 | + |
|
172 | + /** |
|
173 | + * @param string $attention |
|
174 | + */ |
|
175 | + public function set_attention($attention) |
|
176 | + { |
|
177 | + $this->_attention = $attention; |
|
178 | + } |
|
179 | + |
|
180 | + |
|
181 | + /** |
|
182 | + * @return string |
|
183 | + */ |
|
184 | + public function attention() |
|
185 | + { |
|
186 | + return $this->_attention; |
|
187 | + } |
|
188 | + |
|
189 | + |
|
190 | + /** |
|
191 | + * @param string $errors |
|
192 | + */ |
|
193 | + public function set_errors($errors) |
|
194 | + { |
|
195 | + $this->_errors = $errors; |
|
196 | + } |
|
197 | + |
|
198 | + |
|
199 | + /** |
|
200 | + * @return string |
|
201 | + */ |
|
202 | + public function errors() |
|
203 | + { |
|
204 | + return $this->_errors; |
|
205 | + } |
|
206 | + |
|
207 | + |
|
208 | + /** |
|
209 | + * @return string |
|
210 | + */ |
|
211 | + public function unexpected_errors() |
|
212 | + { |
|
213 | + return $this->_unexpected_errors; |
|
214 | + } |
|
215 | + |
|
216 | + |
|
217 | + /** |
|
218 | + * @param string $unexpected_errors |
|
219 | + */ |
|
220 | + public function set_unexpected_errors($unexpected_errors) |
|
221 | + { |
|
222 | + $this->_unexpected_errors = $unexpected_errors; |
|
223 | + } |
|
224 | + |
|
225 | + |
|
226 | + /** |
|
227 | + * @param string $success |
|
228 | + */ |
|
229 | + public function set_success($success) |
|
230 | + { |
|
231 | + $this->_success = $success; |
|
232 | + } |
|
233 | + |
|
234 | + |
|
235 | + /** |
|
236 | + * @return string |
|
237 | + */ |
|
238 | + public function success() |
|
239 | + { |
|
240 | + return $this->_success; |
|
241 | + } |
|
242 | + |
|
243 | + |
|
244 | + /** |
|
245 | + * @param string $method_of_payment |
|
246 | + */ |
|
247 | + public function set_method_of_payment($method_of_payment) |
|
248 | + { |
|
249 | + $this->_method_of_payment = $method_of_payment; |
|
250 | + } |
|
251 | + |
|
252 | + |
|
253 | + /** |
|
254 | + * @return string |
|
255 | + */ |
|
256 | + public function method_of_payment() |
|
257 | + { |
|
258 | + return $this->_method_of_payment; |
|
259 | + } |
|
260 | + |
|
261 | + |
|
262 | + /** |
|
263 | + * @return float |
|
264 | + */ |
|
265 | + public function payment_amount() |
|
266 | + { |
|
267 | + return $this->_payment_amount; |
|
268 | + } |
|
269 | + |
|
270 | + |
|
271 | + /** |
|
272 | + * @param float $payment_amount |
|
273 | + * @throws EE_Error |
|
274 | + */ |
|
275 | + public function set_payment_amount($payment_amount) |
|
276 | + { |
|
277 | + $this->_payment_amount = (float) $payment_amount; |
|
278 | + } |
|
279 | + |
|
280 | + |
|
281 | + /** |
|
282 | + * @param string $next_step_html |
|
283 | + */ |
|
284 | + public function set_reg_step_html($next_step_html) |
|
285 | + { |
|
286 | + $this->_reg_step_html = $next_step_html; |
|
287 | + } |
|
288 | + |
|
289 | + |
|
290 | + /** |
|
291 | + * @return string |
|
292 | + */ |
|
293 | + public function reg_step_html() |
|
294 | + { |
|
295 | + return $this->_reg_step_html; |
|
296 | + } |
|
297 | + |
|
298 | + |
|
299 | + /** |
|
300 | + * @param string $redirect_form |
|
301 | + */ |
|
302 | + public function set_redirect_form($redirect_form) |
|
303 | + { |
|
304 | + $this->_redirect_form = $redirect_form; |
|
305 | + } |
|
306 | + |
|
307 | + |
|
308 | + /** |
|
309 | + * @return string |
|
310 | + */ |
|
311 | + public function redirect_form() |
|
312 | + { |
|
313 | + return ! empty($this->_redirect_form) ? $this->_redirect_form : false; |
|
314 | + } |
|
315 | + |
|
316 | + |
|
317 | + /** |
|
318 | + * @param string $plz_select_method_of_payment |
|
319 | + */ |
|
320 | + public function set_plz_select_method_of_payment($plz_select_method_of_payment) |
|
321 | + { |
|
322 | + $this->_plz_select_method_of_payment = $plz_select_method_of_payment; |
|
323 | + } |
|
324 | + |
|
325 | + |
|
326 | + /** |
|
327 | + * @return string |
|
328 | + */ |
|
329 | + public function plz_select_method_of_payment() |
|
330 | + { |
|
331 | + return $this->_plz_select_method_of_payment; |
|
332 | + } |
|
333 | + |
|
334 | + |
|
335 | + /** |
|
336 | + * @param string $redirect_url |
|
337 | + */ |
|
338 | + public function set_redirect_url($redirect_url) |
|
339 | + { |
|
340 | + $this->_redirect_url = $redirect_url; |
|
341 | + } |
|
342 | + |
|
343 | + |
|
344 | + /** |
|
345 | + * @return string |
|
346 | + */ |
|
347 | + public function redirect_url() |
|
348 | + { |
|
349 | + return $this->_redirect_url; |
|
350 | + } |
|
351 | + |
|
352 | + |
|
353 | + /** |
|
354 | + * @return string |
|
355 | + */ |
|
356 | + public function registration_time_limit() |
|
357 | + { |
|
358 | + return $this->_registration_time_limit; |
|
359 | + } |
|
360 | + |
|
361 | + |
|
362 | + /** |
|
363 | + * @param string $registration_time_limit |
|
364 | + */ |
|
365 | + public function set_registration_time_limit($registration_time_limit) |
|
366 | + { |
|
367 | + $this->_registration_time_limit = $registration_time_limit; |
|
368 | + } |
|
369 | + |
|
370 | + |
|
371 | + /** |
|
372 | + * @param array $return_data |
|
373 | + */ |
|
374 | + public function set_return_data($return_data) |
|
375 | + { |
|
376 | + $this->_return_data = array_merge($this->_return_data, $return_data); |
|
377 | + } |
|
378 | + |
|
379 | + |
|
380 | + /** |
|
381 | + * @return array |
|
382 | + */ |
|
383 | + public function return_data() |
|
384 | + { |
|
385 | + return $this->_return_data; |
|
386 | + } |
|
387 | + |
|
388 | + |
|
389 | + /** |
|
390 | + * @param array $validation_rules |
|
391 | + */ |
|
392 | + public function add_validation_rules(array $validation_rules = array()) |
|
393 | + { |
|
394 | + if (is_array($validation_rules) && ! empty($validation_rules)) { |
|
395 | + $this->_validation_rules = array_merge($this->_validation_rules, $validation_rules); |
|
396 | + } |
|
397 | + } |
|
398 | + |
|
399 | + |
|
400 | + /** |
|
401 | + * @return array | bool |
|
402 | + */ |
|
403 | + public function validation_rules() |
|
404 | + { |
|
405 | + return ! empty($this->_validation_rules) ? $this->_validation_rules : false; |
|
406 | + } |
|
407 | + |
|
408 | + |
|
409 | + public function echoAndExit() |
|
410 | + { |
|
411 | + exit($this->__toString()); |
|
412 | + } |
|
413 | 413 | } |
@@ -19,1791 +19,1791 @@ |
||
19 | 19 | */ |
20 | 20 | class EED_Single_Page_Checkout extends EED_Module |
21 | 21 | { |
22 | - /** |
|
23 | - * $_initialized - has the SPCO controller already been initialized ? |
|
24 | - * |
|
25 | - * @var bool $_initialized |
|
26 | - */ |
|
27 | - private static $_initialized = false; |
|
28 | - |
|
29 | - |
|
30 | - /** |
|
31 | - * $_checkout_verified - is the EE_Checkout verified as correct for this request ? |
|
32 | - * |
|
33 | - * @var bool $_valid_checkout |
|
34 | - */ |
|
35 | - private static $_checkout_verified = true; |
|
36 | - |
|
37 | - /** |
|
38 | - * $_reg_steps_array - holds initial array of reg steps |
|
39 | - * |
|
40 | - * @var array $_reg_steps_array |
|
41 | - */ |
|
42 | - private static $_reg_steps_array = array(); |
|
43 | - |
|
44 | - /** |
|
45 | - * $checkout - EE_Checkout object for handling the properties of the current checkout process |
|
46 | - * |
|
47 | - * @var EE_Checkout $checkout |
|
48 | - */ |
|
49 | - public $checkout; |
|
50 | - |
|
51 | - /** |
|
52 | - * @var RequestInterface $request |
|
53 | - */ |
|
54 | - protected $request; |
|
55 | - |
|
56 | - |
|
57 | - /** |
|
58 | - * @return EED_Single_Page_Checkout|EED_Module |
|
59 | - * @throws EE_Error |
|
60 | - * @throws ReflectionException |
|
61 | - */ |
|
62 | - public static function instance() |
|
63 | - { |
|
64 | - add_filter('EED_Single_Page_Checkout__SPCO_active', '__return_true'); |
|
65 | - return parent::get_instance(__CLASS__); |
|
66 | - } |
|
67 | - |
|
68 | - |
|
69 | - /** |
|
70 | - * @return EE_CART |
|
71 | - */ |
|
72 | - public function cart() |
|
73 | - { |
|
74 | - return $this->checkout->cart; |
|
75 | - } |
|
76 | - |
|
77 | - |
|
78 | - /** |
|
79 | - * @return RequestInterface |
|
80 | - * @since 4.10.14.p |
|
81 | - */ |
|
82 | - public static function getRequest() |
|
83 | - { |
|
84 | - return LoaderFactory::getLoader()->getShared(RequestInterface::class); |
|
85 | - } |
|
86 | - |
|
87 | - |
|
88 | - /** |
|
89 | - * @return EE_Transaction |
|
90 | - */ |
|
91 | - public function transaction() |
|
92 | - { |
|
93 | - return $this->checkout->transaction; |
|
94 | - } |
|
95 | - |
|
96 | - |
|
97 | - /** |
|
98 | - * set_hooks - for hooking into EE Core, other modules, etc |
|
99 | - * |
|
100 | - * @return void |
|
101 | - * @throws EE_Error |
|
102 | - */ |
|
103 | - public static function set_hooks() |
|
104 | - { |
|
105 | - EED_Single_Page_Checkout::set_definitions(); |
|
106 | - } |
|
107 | - |
|
108 | - |
|
109 | - /** |
|
110 | - * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
111 | - * |
|
112 | - * @return void |
|
113 | - * @throws EE_Error |
|
114 | - */ |
|
115 | - public static function set_hooks_admin() |
|
116 | - { |
|
117 | - EED_Single_Page_Checkout::set_definitions(); |
|
118 | - if (! (defined('DOING_AJAX') && DOING_AJAX)) { |
|
119 | - return; |
|
120 | - } |
|
121 | - // going to start an output buffer in case anything gets accidentally output |
|
122 | - // that might disrupt our JSON response |
|
123 | - ob_start(); |
|
124 | - EED_Single_Page_Checkout::load_reg_steps(); |
|
125 | - // set ajax hooks |
|
126 | - add_action('wp_ajax_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step')); |
|
127 | - add_action('wp_ajax_nopriv_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step')); |
|
128 | - add_action('wp_ajax_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step')); |
|
129 | - add_action('wp_ajax_nopriv_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step')); |
|
130 | - add_action('wp_ajax_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step')); |
|
131 | - add_action('wp_ajax_nopriv_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step')); |
|
132 | - } |
|
133 | - |
|
134 | - |
|
135 | - /** |
|
136 | - * process ajax request |
|
137 | - * |
|
138 | - * @param string $ajax_action |
|
139 | - * @throws EE_Error |
|
140 | - * @throws ReflectionException |
|
141 | - */ |
|
142 | - public static function process_ajax_request($ajax_action) |
|
143 | - { |
|
144 | - $request = EED_Single_Page_Checkout::getRequest(); |
|
145 | - $request->setRequestParam('action', $ajax_action); |
|
146 | - EED_Single_Page_Checkout::instance()->_initialize(); |
|
147 | - } |
|
148 | - |
|
149 | - |
|
150 | - /** |
|
151 | - * ajax display registration step |
|
152 | - * |
|
153 | - * @throws EE_Error |
|
154 | - * @throws ReflectionException |
|
155 | - */ |
|
156 | - public static function display_reg_step() |
|
157 | - { |
|
158 | - EED_Single_Page_Checkout::process_ajax_request('display_spco_reg_step'); |
|
159 | - } |
|
160 | - |
|
161 | - |
|
162 | - /** |
|
163 | - * ajax process registration step |
|
164 | - * |
|
165 | - * @throws EE_Error |
|
166 | - * @throws ReflectionException |
|
167 | - */ |
|
168 | - public static function process_reg_step() |
|
169 | - { |
|
170 | - EED_Single_Page_Checkout::process_ajax_request('process_reg_step'); |
|
171 | - } |
|
172 | - |
|
173 | - |
|
174 | - /** |
|
175 | - * ajax process registration step |
|
176 | - * |
|
177 | - * @throws EE_Error |
|
178 | - * @throws ReflectionException |
|
179 | - */ |
|
180 | - public static function update_reg_step() |
|
181 | - { |
|
182 | - EED_Single_Page_Checkout::process_ajax_request('update_reg_step'); |
|
183 | - } |
|
184 | - |
|
185 | - |
|
186 | - /** |
|
187 | - * update_checkout |
|
188 | - * |
|
189 | - * @return void |
|
190 | - * @throws ReflectionException |
|
191 | - * @throws EE_Error |
|
192 | - */ |
|
193 | - public static function update_checkout() |
|
194 | - { |
|
195 | - EED_Single_Page_Checkout::process_ajax_request('update_checkout'); |
|
196 | - } |
|
197 | - |
|
198 | - |
|
199 | - /** |
|
200 | - * @return void |
|
201 | - * @deprecated 4.10.14.p |
|
202 | - */ |
|
203 | - public static function load_request_handler() |
|
204 | - { |
|
205 | - } |
|
206 | - |
|
207 | - |
|
208 | - /** |
|
209 | - * set_definitions |
|
210 | - * |
|
211 | - * @return void |
|
212 | - * @throws EE_Error |
|
213 | - */ |
|
214 | - public static function set_definitions() |
|
215 | - { |
|
216 | - if (defined('SPCO_BASE_PATH')) { |
|
217 | - return; |
|
218 | - } |
|
219 | - define( |
|
220 | - 'SPCO_BASE_PATH', |
|
221 | - rtrim(str_replace(array('\\', '/'), '/', plugin_dir_path(__FILE__)), '/') . '/' |
|
222 | - ); |
|
223 | - define('SPCO_CSS_URL', plugin_dir_url(__FILE__) . 'css/'); |
|
224 | - define('SPCO_IMG_URL', plugin_dir_url(__FILE__) . 'img/'); |
|
225 | - define('SPCO_JS_URL', plugin_dir_url(__FILE__) . 'js/'); |
|
226 | - define('SPCO_INC_PATH', SPCO_BASE_PATH . 'inc/'); |
|
227 | - define('SPCO_REG_STEPS_PATH', SPCO_BASE_PATH . 'reg_steps/'); |
|
228 | - define('SPCO_TEMPLATES_PATH', SPCO_BASE_PATH . 'templates/'); |
|
229 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder(SPCO_BASE_PATH, true); |
|
230 | - EE_Registry::$i18n_js_strings['registration_expiration_notice'] = EED_Single_Page_Checkout::getRegistrationExpirationNotice( |
|
231 | - ); |
|
232 | - } |
|
233 | - |
|
234 | - |
|
235 | - /** |
|
236 | - * load_reg_steps |
|
237 | - * loads and instantiates each reg step based on the EE_Registry::instance()->CFG->registration->reg_steps array |
|
238 | - * |
|
239 | - * @throws EE_Error |
|
240 | - */ |
|
241 | - public static function load_reg_steps() |
|
242 | - { |
|
243 | - static $reg_steps_loaded = false; |
|
244 | - if ($reg_steps_loaded) { |
|
245 | - return; |
|
246 | - } |
|
247 | - // filter list of reg_steps |
|
248 | - $reg_steps_to_load = (array) apply_filters( |
|
249 | - 'AHEE__SPCO__load_reg_steps__reg_steps_to_load', |
|
250 | - EED_Single_Page_Checkout::get_reg_steps() |
|
251 | - ); |
|
252 | - // sort by key (order) |
|
253 | - ksort($reg_steps_to_load); |
|
254 | - // loop through folders |
|
255 | - foreach ($reg_steps_to_load as $order => $reg_step) { |
|
256 | - // we need a |
|
257 | - if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) { |
|
258 | - // copy over to the reg_steps_array |
|
259 | - EED_Single_Page_Checkout::$_reg_steps_array[ $order ] = $reg_step; |
|
260 | - // register custom key route for each reg step |
|
261 | - // ie: step=>"slug" - this is the entire reason we load the reg steps array now |
|
262 | - EE_Config::register_route( |
|
263 | - $reg_step['slug'], |
|
264 | - 'EED_Single_Page_Checkout', |
|
265 | - 'run', |
|
266 | - 'step' |
|
267 | - ); |
|
268 | - // add AJAX or other hooks |
|
269 | - if (isset($reg_step['has_hooks']) && $reg_step['has_hooks']) { |
|
270 | - // setup autoloaders if necessary |
|
271 | - if (! class_exists($reg_step['class_name'])) { |
|
272 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( |
|
273 | - $reg_step['file_path'], |
|
274 | - true |
|
275 | - ); |
|
276 | - } |
|
277 | - if (is_callable($reg_step['class_name'], 'set_hooks')) { |
|
278 | - call_user_func(array($reg_step['class_name'], 'set_hooks')); |
|
279 | - } |
|
280 | - } |
|
281 | - } |
|
282 | - } |
|
283 | - $reg_steps_loaded = true; |
|
284 | - } |
|
285 | - |
|
286 | - |
|
287 | - /** |
|
288 | - * get_reg_steps |
|
289 | - * |
|
290 | - * @return array |
|
291 | - */ |
|
292 | - public static function get_reg_steps() |
|
293 | - { |
|
294 | - $reg_steps = EE_Registry::instance()->CFG->registration->reg_steps; |
|
295 | - if (empty($reg_steps)) { |
|
296 | - $reg_steps = array( |
|
297 | - 10 => array( |
|
298 | - 'file_path' => SPCO_REG_STEPS_PATH . 'attendee_information', |
|
299 | - 'class_name' => 'EE_SPCO_Reg_Step_Attendee_Information', |
|
300 | - 'slug' => 'attendee_information', |
|
301 | - 'has_hooks' => false, |
|
302 | - ), |
|
303 | - 30 => array( |
|
304 | - 'file_path' => SPCO_REG_STEPS_PATH . 'payment_options', |
|
305 | - 'class_name' => 'EE_SPCO_Reg_Step_Payment_Options', |
|
306 | - 'slug' => 'payment_options', |
|
307 | - 'has_hooks' => true, |
|
308 | - ), |
|
309 | - 999 => array( |
|
310 | - 'file_path' => SPCO_REG_STEPS_PATH . 'finalize_registration', |
|
311 | - 'class_name' => 'EE_SPCO_Reg_Step_Finalize_Registration', |
|
312 | - 'slug' => 'finalize_registration', |
|
313 | - 'has_hooks' => false, |
|
314 | - ), |
|
315 | - ); |
|
316 | - } |
|
317 | - return $reg_steps; |
|
318 | - } |
|
319 | - |
|
320 | - |
|
321 | - /** |
|
322 | - * registration_checkout_for_admin |
|
323 | - * |
|
324 | - * @return string |
|
325 | - * @throws EE_Error |
|
326 | - * @throws ReflectionException |
|
327 | - */ |
|
328 | - public static function registration_checkout_for_admin() |
|
329 | - { |
|
330 | - $request = EED_Single_Page_Checkout::getRequest(); |
|
331 | - $request->setRequestParam('step', 'attendee_information'); |
|
332 | - $request->setRequestParam('action', 'display_spco_reg_step'); |
|
333 | - $request->setRequestParam('process_form_submission', false); |
|
334 | - EED_Single_Page_Checkout::instance()->_initialize(); |
|
335 | - EED_Single_Page_Checkout::instance()->_display_spco_reg_form(); |
|
336 | - return EED_Single_Page_Checkout::getResponse()->getOutput(); |
|
337 | - } |
|
338 | - |
|
339 | - |
|
340 | - /** |
|
341 | - * process_registration_from_admin |
|
342 | - * |
|
343 | - * @return EE_Transaction |
|
344 | - * @throws EE_Error |
|
345 | - * @throws ReflectionException |
|
346 | - */ |
|
347 | - public static function process_registration_from_admin() |
|
348 | - { |
|
349 | - $request = EED_Single_Page_Checkout::getRequest(); |
|
350 | - $request->setRequestParam('step', 'attendee_information'); |
|
351 | - $request->setRequestParam('action', 'process_reg_step'); |
|
352 | - $request->setRequestParam('process_form_submission', true); |
|
353 | - EED_Single_Page_Checkout::instance()->_initialize(); |
|
354 | - if (EED_Single_Page_Checkout::instance()->checkout->current_step->completed()) { |
|
355 | - $final_reg_step = end(EED_Single_Page_Checkout::instance()->checkout->reg_steps); |
|
356 | - if ($final_reg_step instanceof EE_SPCO_Reg_Step_Finalize_Registration) { |
|
357 | - EED_Single_Page_Checkout::instance()->checkout->set_reg_step_initiated($final_reg_step); |
|
358 | - if ($final_reg_step->process_reg_step()) { |
|
359 | - $final_reg_step->set_completed(); |
|
360 | - EED_Single_Page_Checkout::instance()->checkout->update_txn_reg_steps_array(); |
|
361 | - return EED_Single_Page_Checkout::instance()->checkout->transaction; |
|
362 | - } |
|
363 | - } |
|
364 | - } |
|
365 | - return null; |
|
366 | - } |
|
367 | - |
|
368 | - |
|
369 | - /** |
|
370 | - * run |
|
371 | - * |
|
372 | - * @param WP_Query $WP |
|
373 | - * @return void |
|
374 | - */ |
|
375 | - public function run($WP) |
|
376 | - { |
|
377 | - if ( |
|
378 | - $WP instanceof WP_Query |
|
379 | - && $WP->is_main_query() |
|
380 | - && apply_filters('FHEE__EED_Single_Page_Checkout__run', true) |
|
381 | - && $this->_is_reg_checkout() |
|
382 | - ) { |
|
383 | - $this->_initialize(); |
|
384 | - } |
|
385 | - } |
|
386 | - |
|
387 | - |
|
388 | - /** |
|
389 | - * determines whether current url matches reg page url |
|
390 | - * |
|
391 | - * @return bool |
|
392 | - */ |
|
393 | - protected function _is_reg_checkout() |
|
394 | - { |
|
395 | - // get current permalink for reg page without any extra query args |
|
396 | - $reg_page_url = get_permalink(EE_Config::instance()->core->reg_page_id); |
|
397 | - // get request URI for current request, but without the scheme or host |
|
398 | - $current_request_uri = EEH_URL::filter_input_server_url(); |
|
399 | - $current_request_uri = html_entity_decode($current_request_uri); |
|
400 | - // get array of query args from the current request URI |
|
401 | - $query_args = EEH_URL::get_query_string($current_request_uri); |
|
402 | - // grab page id if it is set |
|
403 | - $page_id = isset($query_args['page_id']) ? absint($query_args['page_id']) : 0; |
|
404 | - // and remove the page id from the query args (we will re-add it later) |
|
405 | - unset($query_args['page_id']); |
|
406 | - // now strip all query args from current request URI |
|
407 | - $current_request_uri = remove_query_arg(array_keys($query_args), $current_request_uri); |
|
408 | - // and re-add the page id if it was set |
|
409 | - if ($page_id) { |
|
410 | - $current_request_uri = add_query_arg('page_id', $page_id, $current_request_uri); |
|
411 | - } |
|
412 | - // remove slashes and ? |
|
413 | - $current_request_uri = trim($current_request_uri, '?/'); |
|
414 | - // is current request URI part of the known full reg page URL ? |
|
415 | - return ! empty($current_request_uri) && strpos($reg_page_url, $current_request_uri) !== false; |
|
416 | - } |
|
417 | - |
|
418 | - |
|
419 | - /** |
|
420 | - * @param WP_Query $wp_query |
|
421 | - * @return void |
|
422 | - * @throws EE_Error |
|
423 | - * @throws ReflectionException |
|
424 | - */ |
|
425 | - public static function init($wp_query) |
|
426 | - { |
|
427 | - EED_Single_Page_Checkout::instance()->run($wp_query); |
|
428 | - } |
|
429 | - |
|
430 | - |
|
431 | - /** |
|
432 | - * _initialize - initial module setup |
|
433 | - * |
|
434 | - * @return void |
|
435 | - */ |
|
436 | - private function _initialize() |
|
437 | - { |
|
438 | - // ensure SPCO doesn't run twice |
|
439 | - if (EED_Single_Page_Checkout::$_initialized) { |
|
440 | - return; |
|
441 | - } |
|
442 | - try { |
|
443 | - $this->request = EED_Single_Page_Checkout::getRequest(); |
|
444 | - EED_Single_Page_Checkout::load_reg_steps(); |
|
445 | - $this->_verify_session(); |
|
446 | - // setup the EE_Checkout object |
|
447 | - $this->checkout = $this->_initialize_checkout(); |
|
448 | - // filter checkout |
|
449 | - $this->checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize__checkout', $this->checkout); |
|
450 | - // get the $_GET |
|
451 | - $this->_get_request_vars(); |
|
452 | - if ($this->_block_bots()) { |
|
453 | - return; |
|
454 | - } |
|
455 | - // filter continue_reg |
|
456 | - $this->checkout->continue_reg = apply_filters( |
|
457 | - 'FHEE__EED_Single_Page_Checkout__init___continue_reg', |
|
458 | - true, |
|
459 | - $this->checkout |
|
460 | - ); |
|
461 | - // load the reg steps array |
|
462 | - if (! $this->_load_and_instantiate_reg_steps()) { |
|
463 | - EED_Single_Page_Checkout::$_initialized = true; |
|
464 | - return; |
|
465 | - } |
|
466 | - // set the current step |
|
467 | - $this->checkout->set_current_step($this->checkout->step); |
|
468 | - // and the next step |
|
469 | - $this->checkout->set_next_step(); |
|
470 | - // verify that everything has been setup correctly |
|
471 | - if (! ($this->_verify_transaction_and_get_registrations() && $this->_final_verifications())) { |
|
472 | - EED_Single_Page_Checkout::$_initialized = true; |
|
473 | - return; |
|
474 | - } |
|
475 | - // lock the transaction |
|
476 | - $this->checkout->transaction->lock(); |
|
477 | - // make sure all of our cached objects are added to their respective model entity mappers |
|
478 | - $this->checkout->refresh_all_entities(); |
|
479 | - // set amount owing |
|
480 | - $this->checkout->amount_owing = $this->checkout->transaction->remaining(); |
|
481 | - // initialize each reg step, which gives them the chance to potentially alter the process |
|
482 | - $this->_initialize_reg_steps(); |
|
483 | - // DEBUG LOG |
|
484 | - // $this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ ); |
|
485 | - // get reg form |
|
486 | - if (! $this->_check_form_submission()) { |
|
487 | - EED_Single_Page_Checkout::$_initialized = true; |
|
488 | - return; |
|
489 | - } |
|
490 | - // checkout the action!!! |
|
491 | - $this->_process_form_action(); |
|
492 | - // add some style and make it dance |
|
493 | - $this->add_styles_and_scripts($this); |
|
494 | - // kk... SPCO has successfully run |
|
495 | - EED_Single_Page_Checkout::$_initialized = true; |
|
496 | - // set no cache headers and constants |
|
497 | - EE_System::do_not_cache(); |
|
498 | - // add anchor |
|
499 | - add_action('loop_start', array($this, 'set_checkout_anchor'), 1); |
|
500 | - // remove transaction lock |
|
501 | - add_action('shutdown', array($this, 'unlock_transaction'), 1); |
|
502 | - } catch (Exception $e) { |
|
503 | - EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
504 | - } |
|
505 | - } |
|
506 | - |
|
507 | - |
|
508 | - /** |
|
509 | - * _verify_session |
|
510 | - * checks that the session is valid and not expired |
|
511 | - * |
|
512 | - * @throws EE_Error |
|
513 | - * @throws ReflectionException |
|
514 | - */ |
|
515 | - private function _verify_session() |
|
516 | - { |
|
517 | - if (! EE_Registry::instance()->SSN instanceof EE_Session) { |
|
518 | - throw new EE_Error(esc_html__('The EE_Session class could not be loaded.', 'event_espresso')); |
|
519 | - } |
|
520 | - $clear_session_requested = $this->request->getRequestParam('clear_session', false, 'bool'); |
|
521 | - // is session still valid ? |
|
522 | - if ( |
|
523 | - $clear_session_requested |
|
524 | - || ( |
|
525 | - EE_Registry::instance()->SSN->expired() |
|
526 | - && $this->request->getRequestParam('e_reg_url_link') === '' |
|
527 | - ) |
|
528 | - ) { |
|
529 | - $this->checkout = new EE_Checkout(); |
|
530 | - EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
531 | - // EE_Registry::instance()->SSN->reset_cart(); |
|
532 | - // EE_Registry::instance()->SSN->reset_checkout(); |
|
533 | - // EE_Registry::instance()->SSN->reset_transaction(); |
|
534 | - if (! $clear_session_requested) { |
|
535 | - EE_Error::add_attention( |
|
536 | - EE_Registry::$i18n_js_strings['registration_expiration_notice'], |
|
537 | - __FILE__, |
|
538 | - __FUNCTION__, |
|
539 | - __LINE__ |
|
540 | - ); |
|
541 | - } |
|
542 | - // EE_Registry::instance()->SSN->reset_expired(); |
|
543 | - } |
|
544 | - } |
|
545 | - |
|
546 | - |
|
547 | - /** |
|
548 | - * _initialize_checkout |
|
549 | - * loads and instantiates EE_Checkout |
|
550 | - * |
|
551 | - * @return EE_Checkout |
|
552 | - * @throws EE_Error |
|
553 | - * @throws ReflectionException |
|
554 | - */ |
|
555 | - private function _initialize_checkout() |
|
556 | - { |
|
557 | - // look in session for existing checkout |
|
558 | - /** @type EE_Checkout $checkout */ |
|
559 | - $checkout = EE_Registry::instance()->SSN->checkout(); |
|
560 | - // verify |
|
561 | - if (! $checkout instanceof EE_Checkout) { |
|
562 | - // instantiate EE_Checkout object for handling the properties of the current checkout process |
|
563 | - $checkout = EE_Registry::instance()->load_file( |
|
564 | - SPCO_INC_PATH, |
|
565 | - 'EE_Checkout', |
|
566 | - 'class', |
|
567 | - array(), |
|
568 | - false |
|
569 | - ); |
|
570 | - } else { |
|
571 | - if ($checkout->current_step->is_final_step() && $checkout->exit_spco() === true) { |
|
572 | - $this->unlock_transaction(); |
|
573 | - wp_safe_redirect($checkout->redirect_url); |
|
574 | - exit(); |
|
575 | - } |
|
576 | - } |
|
577 | - $checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize_checkout__checkout', $checkout); |
|
578 | - // verify again |
|
579 | - if (! $checkout instanceof EE_Checkout) { |
|
580 | - throw new EE_Error(esc_html__('The EE_Checkout class could not be loaded.', 'event_espresso')); |
|
581 | - } |
|
582 | - // reset anything that needs a clean slate for each request |
|
583 | - $checkout->reset_for_current_request(); |
|
584 | - return $checkout; |
|
585 | - } |
|
586 | - |
|
587 | - |
|
588 | - /** |
|
589 | - * _get_request_vars |
|
590 | - * |
|
591 | - * @return void |
|
592 | - */ |
|
593 | - private function _get_request_vars() |
|
594 | - { |
|
595 | - // make sure this request is marked as belonging to EE |
|
596 | - /** @var CurrentPage $current_page */ |
|
597 | - $current_page = LoaderFactory::getLoader()->getShared(CurrentPage::class); |
|
598 | - $current_page->setEspressoPage(true); |
|
599 | - // which step is being requested ? |
|
600 | - $this->checkout->step = $this->request->getRequestParam('step', $this->_get_first_step()); |
|
601 | - // which step is being edited ? |
|
602 | - $this->checkout->edit_step = $this->request->getRequestParam('edit_step'); |
|
603 | - // and what we're doing on the current step |
|
604 | - $this->checkout->action = $this->request->getRequestParam('action', 'display_spco_reg_step'); |
|
605 | - // timestamp |
|
606 | - $this->checkout->uts = $this->request->getRequestParam('uts', 0, 'int'); |
|
607 | - // returning to edit ? |
|
608 | - $this->checkout->reg_url_link = $this->request->getRequestParam('e_reg_url_link'); |
|
609 | - // add reg url link to registration query params |
|
610 | - if ($this->checkout->reg_url_link && strpos($this->checkout->reg_url_link, '1-') !== 0) { |
|
611 | - $this->checkout->reg_cache_where_params[0]['REG_url_link'] = $this->checkout->reg_url_link; |
|
612 | - } |
|
613 | - // or some other kind of revisit ? |
|
614 | - $this->checkout->revisit = $this->request->getRequestParam('revisit', false, 'bool'); |
|
615 | - // and whether or not to generate a reg form for this request |
|
616 | - $this->checkout->generate_reg_form = $this->request->getRequestParam('generate_reg_form', true, 'bool'); |
|
617 | - // and whether or not to process a reg form submission for this request |
|
618 | - $this->checkout->process_form_submission = $this->request->getRequestParam( |
|
619 | - 'process_form_submission', |
|
620 | - $this->checkout->action === 'process_reg_step', |
|
621 | - 'bool' |
|
622 | - ); |
|
623 | - $this->checkout->process_form_submission = filter_var( |
|
624 | - $this->checkout->action !== 'display_spco_reg_step' |
|
625 | - ? $this->checkout->process_form_submission |
|
626 | - : false, |
|
627 | - FILTER_VALIDATE_BOOLEAN |
|
628 | - ); |
|
629 | - // $this->_display_request_vars(); |
|
630 | - } |
|
631 | - |
|
632 | - |
|
633 | - /** |
|
634 | - * _display_request_vars |
|
635 | - * |
|
636 | - * @return void |
|
637 | - */ |
|
638 | - protected function _display_request_vars() |
|
639 | - { |
|
640 | - if (! WP_DEBUG) { |
|
641 | - return; |
|
642 | - } |
|
643 | - EEH_Debug_Tools::printr($this->request->requestParams(), 'requestParams', __FILE__, __LINE__); |
|
644 | - EEH_Debug_Tools::printr($this->checkout->step, '$this->checkout->step', __FILE__, __LINE__); |
|
645 | - EEH_Debug_Tools::printr($this->checkout->edit_step, '$this->checkout->edit_step', __FILE__, __LINE__); |
|
646 | - EEH_Debug_Tools::printr($this->checkout->action, '$this->checkout->action', __FILE__, __LINE__); |
|
647 | - EEH_Debug_Tools::printr($this->checkout->reg_url_link, '$this->checkout->reg_url_link', __FILE__, __LINE__); |
|
648 | - EEH_Debug_Tools::printr($this->checkout->revisit, '$this->checkout->revisit', __FILE__, __LINE__); |
|
649 | - EEH_Debug_Tools::printr( |
|
650 | - $this->checkout->generate_reg_form, |
|
651 | - '$this->checkout->generate_reg_form', |
|
652 | - __FILE__, |
|
653 | - __LINE__ |
|
654 | - ); |
|
655 | - EEH_Debug_Tools::printr( |
|
656 | - $this->checkout->process_form_submission, |
|
657 | - '$this->checkout->process_form_submission', |
|
658 | - __FILE__, |
|
659 | - __LINE__ |
|
660 | - ); |
|
661 | - } |
|
662 | - |
|
663 | - |
|
664 | - /** |
|
665 | - * _block_bots |
|
666 | - * checks that the incoming request has either of the following set: |
|
667 | - * a uts (unix timestamp) which indicates that the request was redirected from the Ticket Selector |
|
668 | - * a REG URL Link, which indicates that the request is a return visit to SPCO for a valid TXN |
|
669 | - * so if you're not coming from the Ticket Selector nor returning for a valid IP... |
|
670 | - * then where you coming from man? |
|
671 | - * |
|
672 | - * @return boolean |
|
673 | - */ |
|
674 | - private function _block_bots() |
|
675 | - { |
|
676 | - $invalid_checkout_access = EED_Invalid_Checkout_Access::getInvalidCheckoutAccess(); |
|
677 | - if ($invalid_checkout_access->checkoutAccessIsInvalid($this->checkout)) { |
|
678 | - return true; |
|
679 | - } |
|
680 | - return false; |
|
681 | - } |
|
682 | - |
|
683 | - |
|
684 | - /** |
|
685 | - * _get_first_step |
|
686 | - * gets slug for first step in $_reg_steps_array |
|
687 | - * |
|
688 | - * @return string |
|
689 | - */ |
|
690 | - private function _get_first_step() |
|
691 | - { |
|
692 | - $first_step = reset(EED_Single_Page_Checkout::$_reg_steps_array); |
|
693 | - return isset($first_step['slug']) ? $first_step['slug'] : 'attendee_information'; |
|
694 | - } |
|
695 | - |
|
696 | - |
|
697 | - /** |
|
698 | - * instantiates each reg step based on the loaded reg_steps array |
|
699 | - * |
|
700 | - * @return bool |
|
701 | - * @throws EE_Error |
|
702 | - * @throws InvalidArgumentException |
|
703 | - * @throws InvalidDataTypeException |
|
704 | - * @throws InvalidInterfaceException |
|
705 | - * @throws ReflectionException |
|
706 | - */ |
|
707 | - private function _load_and_instantiate_reg_steps() |
|
708 | - { |
|
709 | - do_action('AHEE__Single_Page_Checkout___load_and_instantiate_reg_steps__start', $this->checkout); |
|
710 | - // have reg_steps already been instantiated ? |
|
711 | - if ( |
|
712 | - empty($this->checkout->reg_steps) |
|
713 | - || apply_filters('FHEE__Single_Page_Checkout__load_reg_steps__reload_reg_steps', false, $this->checkout) |
|
714 | - ) { |
|
715 | - // if not, then loop through raw reg steps array |
|
716 | - foreach (EED_Single_Page_Checkout::$_reg_steps_array as $order => $reg_step) { |
|
717 | - if (! $this->_load_and_instantiate_reg_step($reg_step, $order)) { |
|
718 | - return false; |
|
719 | - } |
|
720 | - } |
|
721 | - if (isset($this->checkout->reg_steps['registration_confirmation'])) { |
|
722 | - // skip the registration_confirmation page ? |
|
723 | - if (EE_Registry::instance()->CFG->registration->skip_reg_confirmation) { |
|
724 | - // just remove it from the reg steps array |
|
725 | - $this->checkout->remove_reg_step('registration_confirmation', false); |
|
726 | - } elseif ( |
|
727 | - EE_Registry::instance()->CFG->registration->reg_confirmation_last |
|
728 | - ) { |
|
729 | - // set the order to something big like 100 |
|
730 | - $this->checkout->set_reg_step_order('registration_confirmation'); |
|
731 | - } |
|
732 | - } |
|
733 | - // filter the array for good luck |
|
734 | - $this->checkout->reg_steps = apply_filters( |
|
735 | - 'FHEE__Single_Page_Checkout__load_reg_steps__reg_steps', |
|
736 | - $this->checkout->reg_steps |
|
737 | - ); |
|
738 | - // finally re-sort based on the reg step class order properties |
|
739 | - $this->checkout->sort_reg_steps(); |
|
740 | - } else { |
|
741 | - foreach ($this->checkout->reg_steps as $reg_step) { |
|
742 | - // set all current step stati to FALSE |
|
743 | - $reg_step->set_is_current_step(false); |
|
744 | - } |
|
745 | - } |
|
746 | - if (empty($this->checkout->reg_steps)) { |
|
747 | - EE_Error::add_error( |
|
748 | - esc_html__('No Reg Steps were loaded..', 'event_espresso'), |
|
749 | - __FILE__, |
|
750 | - __FUNCTION__, |
|
751 | - __LINE__ |
|
752 | - ); |
|
753 | - return false; |
|
754 | - } |
|
755 | - // make reg step details available to JS |
|
756 | - $this->checkout->set_reg_step_JSON_info(); |
|
757 | - return true; |
|
758 | - } |
|
759 | - |
|
760 | - |
|
761 | - /** |
|
762 | - * _load_and_instantiate_reg_step |
|
763 | - * |
|
764 | - * @param array $reg_step |
|
765 | - * @param int $order |
|
766 | - * @return bool |
|
767 | - * @throws EE_Error |
|
768 | - * @throws ReflectionException |
|
769 | - */ |
|
770 | - private function _load_and_instantiate_reg_step($reg_step = array(), $order = 0) |
|
771 | - { |
|
772 | - // we need a file_path, class_name, and slug to add a reg step |
|
773 | - if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) { |
|
774 | - // if editing a specific step, but this is NOT that step... (and it's not the 'finalize_registration' step) |
|
775 | - if ( |
|
776 | - $this->checkout->reg_url_link |
|
777 | - && $this->checkout->step !== $reg_step['slug'] |
|
778 | - && $reg_step['slug'] !== 'finalize_registration' |
|
779 | - // normally at this point we would NOT load the reg step, but this filter can change that |
|
780 | - && apply_filters( |
|
781 | - 'FHEE__Single_Page_Checkout___load_and_instantiate_reg_step__bypass_reg_step', |
|
782 | - true, |
|
783 | - $reg_step, |
|
784 | - $this->checkout |
|
785 | - ) |
|
786 | - ) { |
|
787 | - return true; |
|
788 | - } |
|
789 | - |
|
790 | - // instantiate step class using file path and class name |
|
791 | - $reg_step_obj = EE_Registry::instance()->load_file( |
|
792 | - $reg_step['file_path'], |
|
793 | - $reg_step['class_name'], |
|
794 | - 'class', |
|
795 | - [$this->checkout], |
|
796 | - false |
|
797 | - ); |
|
798 | - // did we gets the goods ? |
|
799 | - if ($reg_step_obj instanceof EE_SPCO_Reg_Step) { |
|
800 | - // set reg step order based on config |
|
801 | - $reg_step_obj->set_order($order); |
|
802 | - // add instantiated reg step object to the master reg steps array |
|
803 | - $this->checkout->add_reg_step($reg_step_obj); |
|
804 | - } else { |
|
805 | - EE_Error::add_error( |
|
806 | - esc_html__('The current step could not be set.', 'event_espresso'), |
|
807 | - __FILE__, |
|
808 | - __FUNCTION__, |
|
809 | - __LINE__ |
|
810 | - ); |
|
811 | - return false; |
|
812 | - } |
|
813 | - } else { |
|
814 | - if (WP_DEBUG) { |
|
815 | - EE_Error::add_error( |
|
816 | - sprintf( |
|
817 | - esc_html__( |
|
818 | - 'A registration step could not be loaded. One or more of the following data points is invalid:%4$s%5$sFile Path: %1$s%6$s%5$sClass Name: %2$s%6$s%5$sSlug: %3$s%6$s%7$s', |
|
819 | - 'event_espresso' |
|
820 | - ), |
|
821 | - isset($reg_step['file_path']) ? $reg_step['file_path'] : '', |
|
822 | - isset($reg_step['class_name']) ? $reg_step['class_name'] : '', |
|
823 | - isset($reg_step['slug']) ? $reg_step['slug'] : '', |
|
824 | - '<ul>', |
|
825 | - '<li>', |
|
826 | - '</li>', |
|
827 | - '</ul>' |
|
828 | - ), |
|
829 | - __FILE__, |
|
830 | - __FUNCTION__, |
|
831 | - __LINE__ |
|
832 | - ); |
|
833 | - } |
|
834 | - return false; |
|
835 | - } |
|
836 | - return true; |
|
837 | - } |
|
838 | - |
|
839 | - |
|
840 | - /** |
|
841 | - * _verify_transaction_and_get_registrations |
|
842 | - * |
|
843 | - * @return bool |
|
844 | - * @throws EE_Error |
|
845 | - * @throws ReflectionException |
|
846 | - */ |
|
847 | - private function _verify_transaction_and_get_registrations() |
|
848 | - { |
|
849 | - // was there already a valid transaction in the checkout from the session ? |
|
850 | - if (! $this->checkout->transaction instanceof EE_Transaction) { |
|
851 | - // get transaction from db or session |
|
852 | - $this->checkout->transaction = $this->checkout->reg_url_link && ! is_admin() |
|
853 | - ? $this->_get_transaction_and_cart_for_previous_visit() |
|
854 | - : $this->_get_cart_for_current_session_and_setup_new_transaction(); |
|
855 | - if (! $this->checkout->transaction instanceof EE_Transaction) { |
|
856 | - EE_Error::add_error( |
|
857 | - esc_html__( |
|
858 | - 'Your Registration and Transaction information could not be retrieved from the db.', |
|
859 | - 'event_espresso' |
|
860 | - ), |
|
861 | - __FILE__, |
|
862 | - __FUNCTION__, |
|
863 | - __LINE__ |
|
864 | - ); |
|
865 | - $this->checkout->transaction = EE_Transaction::new_instance(); |
|
866 | - // add some style and make it dance |
|
867 | - $this->add_styles_and_scripts($this); |
|
868 | - EED_Single_Page_Checkout::$_initialized = true; |
|
869 | - return false; |
|
870 | - } |
|
871 | - // and the registrations for the transaction |
|
872 | - $this->_get_registrations($this->checkout->transaction); |
|
873 | - } |
|
874 | - return true; |
|
875 | - } |
|
876 | - |
|
877 | - |
|
878 | - /** |
|
879 | - * _get_transaction_and_cart_for_previous_visit |
|
880 | - * |
|
881 | - * @return EE_Transaction|null |
|
882 | - * @throws EE_Error |
|
883 | - * @throws ReflectionException |
|
884 | - */ |
|
885 | - private function _get_transaction_and_cart_for_previous_visit() |
|
886 | - { |
|
887 | - /** @var $TXN_model EEM_Transaction */ |
|
888 | - $TXN_model = EE_Registry::instance()->load_model('Transaction'); |
|
889 | - // because the reg_url_link is present in the request, |
|
890 | - // this is a return visit to SPCO, so we'll get the transaction data from the db |
|
891 | - $transaction = $TXN_model->get_transaction_from_reg_url_link($this->checkout->reg_url_link); |
|
892 | - // verify transaction |
|
893 | - if ($transaction instanceof EE_Transaction) { |
|
894 | - // and get the cart that was used for that transaction |
|
895 | - $this->checkout->cart = $this->_get_cart_for_transaction($transaction); |
|
896 | - return $transaction; |
|
897 | - } |
|
898 | - EE_Error::add_error( |
|
899 | - esc_html__('Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso'), |
|
900 | - __FILE__, |
|
901 | - __FUNCTION__, |
|
902 | - __LINE__ |
|
903 | - ); |
|
904 | - return null; |
|
905 | - } |
|
906 | - |
|
907 | - |
|
908 | - /** |
|
909 | - * _get_cart_for_transaction |
|
910 | - * |
|
911 | - * @param EE_Transaction $transaction |
|
912 | - * @return EE_Cart |
|
913 | - */ |
|
914 | - private function _get_cart_for_transaction($transaction) |
|
915 | - { |
|
916 | - return $this->checkout->get_cart_for_transaction($transaction); |
|
917 | - } |
|
918 | - |
|
919 | - |
|
920 | - /** |
|
921 | - * get_cart_for_transaction |
|
922 | - * |
|
923 | - * @param EE_Transaction $transaction |
|
924 | - * @return EE_Cart |
|
925 | - */ |
|
926 | - public function get_cart_for_transaction(EE_Transaction $transaction) |
|
927 | - { |
|
928 | - return $this->checkout->get_cart_for_transaction($transaction); |
|
929 | - } |
|
930 | - |
|
931 | - |
|
932 | - /** |
|
933 | - * _get_transaction_and_cart_for_current_session |
|
934 | - * generates a new EE_Transaction object and adds it to the $_transaction property. |
|
935 | - * |
|
936 | - * @return EE_Transaction |
|
937 | - * @throws EE_Error |
|
938 | - * @throws ReflectionException |
|
939 | - */ |
|
940 | - private function _get_cart_for_current_session_and_setup_new_transaction() |
|
941 | - { |
|
942 | - // if there's no transaction, then this is the FIRST visit to SPCO |
|
943 | - // so load up the cart ( passing nothing for the TXN because it doesn't exist yet ) |
|
944 | - $this->checkout->cart = $this->_get_cart_for_transaction(null); |
|
945 | - // and then create a new transaction |
|
946 | - $transaction = $this->_initialize_transaction(); |
|
947 | - // verify transaction |
|
948 | - if ($transaction instanceof EE_Transaction) { |
|
949 | - // save it so that we have an ID for other objects to use |
|
950 | - $transaction->save(); |
|
951 | - // and save TXN data to the cart |
|
952 | - $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn($transaction->ID()); |
|
953 | - } else { |
|
954 | - EE_Error::add_error( |
|
955 | - esc_html__('A Valid Transaction could not be initialized.', 'event_espresso'), |
|
956 | - __FILE__, |
|
957 | - __FUNCTION__, |
|
958 | - __LINE__ |
|
959 | - ); |
|
960 | - } |
|
961 | - return $transaction; |
|
962 | - } |
|
963 | - |
|
964 | - |
|
965 | - /** |
|
966 | - * generates a new EE_Transaction object and adds it to the $_transaction property. |
|
967 | - * |
|
968 | - * @return EE_Transaction|null |
|
969 | - */ |
|
970 | - private function _initialize_transaction() |
|
971 | - { |
|
972 | - try { |
|
973 | - // ensure cart totals have been calculated |
|
974 | - $this->checkout->cart->get_grand_total()->recalculate_total_including_taxes(); |
|
975 | - // grab the cart grand total |
|
976 | - $cart_total = $this->checkout->cart->get_cart_grand_total(); |
|
977 | - // create new TXN |
|
978 | - $transaction = EE_Transaction::new_instance( |
|
979 | - array( |
|
980 | - 'TXN_reg_steps' => $this->checkout->initialize_txn_reg_steps_array(), |
|
981 | - 'TXN_total' => $cart_total > 0 ? $cart_total : 0, |
|
982 | - 'TXN_paid' => 0, |
|
983 | - 'STS_ID' => EEM_Transaction::failed_status_code, |
|
984 | - ) |
|
985 | - ); |
|
986 | - // save it so that we have an ID for other objects to use |
|
987 | - $transaction->save(); |
|
988 | - // set cron job for following up on TXNs after their session has expired |
|
989 | - EE_Cron_Tasks::schedule_expired_transaction_check( |
|
990 | - EE_Registry::instance()->SSN->expiration() + 1, |
|
991 | - $transaction->ID() |
|
992 | - ); |
|
993 | - return $transaction; |
|
994 | - } catch (Exception $e) { |
|
995 | - EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
996 | - } |
|
997 | - return null; |
|
998 | - } |
|
999 | - |
|
1000 | - |
|
1001 | - /** |
|
1002 | - * _get_registrations |
|
1003 | - * |
|
1004 | - * @param EE_Transaction $transaction |
|
1005 | - * @return void |
|
1006 | - * @throws EE_Error |
|
1007 | - * @throws ReflectionException |
|
1008 | - */ |
|
1009 | - private function _get_registrations(EE_Transaction $transaction) |
|
1010 | - { |
|
1011 | - // first step: grab the registrants { : o |
|
1012 | - $registrations = $transaction->registrations($this->checkout->reg_cache_where_params); |
|
1013 | - $this->checkout->total_ticket_count = count($registrations); |
|
1014 | - // verify registrations have been set |
|
1015 | - if (empty($registrations)) { |
|
1016 | - // if no cached registrations, then check the db |
|
1017 | - $registrations = $transaction->registrations($this->checkout->reg_cache_where_params); |
|
1018 | - // still nothing ? well as long as this isn't a revisit |
|
1019 | - if (empty($registrations) && ! $this->checkout->revisit) { |
|
1020 | - // generate new registrations from scratch |
|
1021 | - $registrations = $this->_initialize_registrations($transaction); |
|
1022 | - } |
|
1023 | - } |
|
1024 | - // sort by their original registration order |
|
1025 | - usort($registrations, array('EED_Single_Page_Checkout', 'sort_registrations_by_REG_count')); |
|
1026 | - // then loop thru the array |
|
1027 | - foreach ($registrations as $registration) { |
|
1028 | - // verify each registration |
|
1029 | - if ($registration instanceof EE_Registration) { |
|
1030 | - // we display all attendee info for the primary registrant |
|
1031 | - if ( |
|
1032 | - $this->checkout->reg_url_link === $registration->reg_url_link() |
|
1033 | - && $registration->is_primary_registrant() |
|
1034 | - ) { |
|
1035 | - $this->checkout->primary_revisit = true; |
|
1036 | - break; |
|
1037 | - } |
|
1038 | - if ($this->checkout->revisit && $this->checkout->reg_url_link !== $registration->reg_url_link()) { |
|
1039 | - // but hide info if it doesn't belong to you |
|
1040 | - $transaction->clear_cache('Registration', $registration->ID()); |
|
1041 | - $this->checkout->total_ticket_count--; |
|
1042 | - } |
|
1043 | - $this->checkout->set_reg_status_updated($registration->ID(), false); |
|
1044 | - } |
|
1045 | - } |
|
1046 | - } |
|
1047 | - |
|
1048 | - |
|
1049 | - /** |
|
1050 | - * adds related EE_Registration objects for each ticket in the cart to the current EE_Transaction object |
|
1051 | - * |
|
1052 | - * @param EE_Transaction $transaction |
|
1053 | - * @return array |
|
1054 | - * @throws EE_Error |
|
1055 | - * @throws ReflectionException |
|
1056 | - */ |
|
1057 | - private function _initialize_registrations(EE_Transaction $transaction) |
|
1058 | - { |
|
1059 | - $att_nmbr = 0; |
|
1060 | - $registrations = array(); |
|
1061 | - if ($transaction instanceof EE_Transaction) { |
|
1062 | - /** @type EE_Registration_Processor $registration_processor */ |
|
1063 | - $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
1064 | - $this->checkout->total_ticket_count = $this->checkout->cart->all_ticket_quantity_count(); |
|
1065 | - // now let's add the cart items to the $transaction |
|
1066 | - foreach ($this->checkout->cart->get_tickets() as $line_item) { |
|
1067 | - // do the following for each ticket of this type they selected |
|
1068 | - for ($x = 1; $x <= $line_item->quantity(); $x++) { |
|
1069 | - $att_nmbr++; |
|
1070 | - /** @var CreateRegistrationCommand $CreateRegistrationCommand */ |
|
1071 | - $CreateRegistrationCommand = EE_Registry::instance()->create( |
|
1072 | - CreateRegistrationCommand::class, |
|
1073 | - [ |
|
1074 | - $transaction, |
|
1075 | - $line_item, |
|
1076 | - $att_nmbr, |
|
1077 | - $this->checkout->total_ticket_count, |
|
1078 | - ] |
|
1079 | - ); |
|
1080 | - // override capabilities for frontend registrations |
|
1081 | - if ($this->request->isFrontend()) { |
|
1082 | - $CreateRegistrationCommand->setCapCheck( |
|
1083 | - new PublicCapabilities('', 'create_new_registration') |
|
1084 | - ); |
|
1085 | - } |
|
1086 | - $registration = EE_Registry::instance()->BUS->execute($CreateRegistrationCommand); |
|
1087 | - if (! $registration instanceof EE_Registration) { |
|
1088 | - throw new InvalidEntityException($registration, 'EE_Registration'); |
|
1089 | - } |
|
1090 | - $registrations[ $registration->ID() ] = $registration; |
|
1091 | - } |
|
1092 | - } |
|
1093 | - $registration_processor->fix_reg_final_price_rounding_issue($transaction); |
|
1094 | - } |
|
1095 | - return $registrations; |
|
1096 | - } |
|
1097 | - |
|
1098 | - |
|
1099 | - /** |
|
1100 | - * sorts registrations by REG_count |
|
1101 | - * |
|
1102 | - * @param EE_Registration $reg_A |
|
1103 | - * @param EE_Registration $reg_B |
|
1104 | - * @return int |
|
1105 | - */ |
|
1106 | - public static function sort_registrations_by_REG_count(EE_Registration $reg_A, EE_Registration $reg_B) |
|
1107 | - { |
|
1108 | - // this shouldn't ever happen within the same TXN, but oh well |
|
1109 | - if ($reg_A->count() === $reg_B->count()) { |
|
1110 | - return 0; |
|
1111 | - } |
|
1112 | - return ($reg_A->count() > $reg_B->count()) ? 1 : -1; |
|
1113 | - } |
|
1114 | - |
|
1115 | - |
|
1116 | - /** |
|
1117 | - * _final_verifications |
|
1118 | - * just makes sure that everything is set up correctly before proceeding |
|
1119 | - * |
|
1120 | - * @return bool |
|
1121 | - * @throws EE_Error |
|
1122 | - * @throws ReflectionException |
|
1123 | - */ |
|
1124 | - private function _final_verifications() |
|
1125 | - { |
|
1126 | - // filter checkout |
|
1127 | - $this->checkout = apply_filters( |
|
1128 | - 'FHEE__EED_Single_Page_Checkout___final_verifications__checkout', |
|
1129 | - $this->checkout |
|
1130 | - ); |
|
1131 | - // verify that current step is still set correctly |
|
1132 | - if (! $this->checkout->current_step instanceof EE_SPCO_Reg_Step) { |
|
1133 | - EE_Error::add_error( |
|
1134 | - esc_html__( |
|
1135 | - 'We\'re sorry but the registration process can not proceed because one or more registration steps were not setup correctly. Please refresh the page and try again or contact support.', |
|
1136 | - 'event_espresso' |
|
1137 | - ), |
|
1138 | - __FILE__, |
|
1139 | - __FUNCTION__, |
|
1140 | - __LINE__ |
|
1141 | - ); |
|
1142 | - return false; |
|
1143 | - } |
|
1144 | - // if returning to SPCO, then verify that primary registrant is set |
|
1145 | - if (! empty($this->checkout->reg_url_link)) { |
|
1146 | - $valid_registrant = $this->checkout->transaction->primary_registration(); |
|
1147 | - if (! $valid_registrant instanceof EE_Registration) { |
|
1148 | - EE_Error::add_error( |
|
1149 | - esc_html__( |
|
1150 | - 'We\'re sorry but there appears to be an error with the "reg_url_link" or the primary registrant for this transaction. Please refresh the page and try again or contact support.', |
|
1151 | - 'event_espresso' |
|
1152 | - ), |
|
1153 | - __FILE__, |
|
1154 | - __FUNCTION__, |
|
1155 | - __LINE__ |
|
1156 | - ); |
|
1157 | - return false; |
|
1158 | - } |
|
1159 | - $valid_registrant = null; |
|
1160 | - foreach ($this->checkout->transaction->registrations($this->checkout->reg_cache_where_params) as $registration) { |
|
1161 | - if ( |
|
1162 | - $registration instanceof EE_Registration |
|
1163 | - && $registration->reg_url_link() === $this->checkout->reg_url_link |
|
1164 | - ) { |
|
1165 | - $valid_registrant = $registration; |
|
1166 | - } |
|
1167 | - } |
|
1168 | - if (! $valid_registrant instanceof EE_Registration) { |
|
1169 | - // hmmm... maybe we have the wrong session because the user is opening multiple tabs ? |
|
1170 | - if (EED_Single_Page_Checkout::$_checkout_verified) { |
|
1171 | - // clear the session, mark the checkout as unverified, and try again |
|
1172 | - EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
1173 | - EED_Single_Page_Checkout::$_initialized = false; |
|
1174 | - EED_Single_Page_Checkout::$_checkout_verified = false; |
|
1175 | - $this->_initialize(); |
|
1176 | - EE_Error::reset_notices(); |
|
1177 | - return false; |
|
1178 | - } |
|
1179 | - EE_Error::add_error( |
|
1180 | - esc_html__( |
|
1181 | - 'We\'re sorry but there appears to be an error with the "reg_url_link" or the transaction itself. Please refresh the page and try again or contact support.', |
|
1182 | - 'event_espresso' |
|
1183 | - ), |
|
1184 | - __FILE__, |
|
1185 | - __FUNCTION__, |
|
1186 | - __LINE__ |
|
1187 | - ); |
|
1188 | - return false; |
|
1189 | - } |
|
1190 | - } |
|
1191 | - // now that things have been kinda sufficiently verified, |
|
1192 | - // let's add the checkout to the session so that it's available to other systems |
|
1193 | - EE_Registry::instance()->SSN->set_checkout($this->checkout); |
|
1194 | - return true; |
|
1195 | - } |
|
1196 | - |
|
1197 | - |
|
1198 | - /** |
|
1199 | - * _initialize_reg_steps |
|
1200 | - * first makes sure that EE_Transaction_Processor::set_reg_step_initiated() is called as required |
|
1201 | - * then loops thru all of the active reg steps and calls the initialize_reg_step() method |
|
1202 | - * |
|
1203 | - * @param bool $reinitializing |
|
1204 | - * @throws EE_Error |
|
1205 | - */ |
|
1206 | - private function _initialize_reg_steps($reinitializing = false) |
|
1207 | - { |
|
1208 | - $this->checkout->set_reg_step_initiated($this->checkout->current_step); |
|
1209 | - // loop thru all steps to call their individual "initialize" methods and set i18n strings for JS |
|
1210 | - foreach ($this->checkout->reg_steps as $reg_step) { |
|
1211 | - if (! $reg_step->initialize_reg_step()) { |
|
1212 | - // if not initialized then maybe this step is being removed... |
|
1213 | - if (! $reinitializing && $reg_step->is_current_step()) { |
|
1214 | - // if it was the current step, then we need to start over here |
|
1215 | - $this->_initialize_reg_steps(true); |
|
1216 | - return; |
|
1217 | - } |
|
1218 | - continue; |
|
1219 | - } |
|
1220 | - // add css and JS for current step |
|
1221 | - $this->add_styles_and_scripts($reg_step); |
|
1222 | - if ($reg_step->is_current_step()) { |
|
1223 | - // the text that appears on the reg step form submit button |
|
1224 | - $reg_step->set_submit_button_text(); |
|
1225 | - } |
|
1226 | - } |
|
1227 | - // dynamically creates hook point like: AHEE__Single_Page_Checkout___initialize_reg_step__attendee_information |
|
1228 | - do_action( |
|
1229 | - "AHEE__Single_Page_Checkout___initialize_reg_step__{$this->checkout->current_step->slug()}", |
|
1230 | - $this->checkout->current_step |
|
1231 | - ); |
|
1232 | - } |
|
1233 | - |
|
1234 | - |
|
1235 | - /** |
|
1236 | - * _check_form_submission |
|
1237 | - * |
|
1238 | - * @return boolean |
|
1239 | - * @throws EE_Error |
|
1240 | - * @throws ReflectionException |
|
1241 | - */ |
|
1242 | - private function _check_form_submission() |
|
1243 | - { |
|
1244 | - // does this request require the reg form to be generated ? |
|
1245 | - if ($this->checkout->generate_reg_form) { |
|
1246 | - // ever heard that song by Blue Rodeo ? |
|
1247 | - try { |
|
1248 | - $this->checkout->current_step->reg_form = $this->checkout->current_step->generate_reg_form(); |
|
1249 | - // if not displaying a form, then check for form submission |
|
1250 | - if ( |
|
1251 | - $this->checkout->process_form_submission |
|
1252 | - && $this->checkout->current_step->reg_form->was_submitted() |
|
1253 | - ) { |
|
1254 | - // clear out any old data in case this step is being run again |
|
1255 | - $this->checkout->current_step->set_valid_data(array()); |
|
1256 | - // capture submitted form data |
|
1257 | - $request_data = $this->request->requestParams(); |
|
1258 | - $this->checkout->current_step->reg_form->receive_form_submission( |
|
1259 | - (array) apply_filters( |
|
1260 | - 'FHEE__Single_Page_Checkout___check_form_submission__request_params', |
|
1261 | - $request_data, |
|
1262 | - $this->checkout |
|
1263 | - ) |
|
1264 | - ); |
|
1265 | - // validate submitted form data |
|
1266 | - if (! $this->checkout->continue_reg || ! $this->checkout->current_step->reg_form->is_valid()) { |
|
1267 | - // thou shall not pass !!! |
|
1268 | - $this->checkout->continue_reg = false; |
|
1269 | - // any form validation errors? |
|
1270 | - if ($this->checkout->current_step->reg_form->submission_error_message() !== '') { |
|
1271 | - EE_Error::add_error( |
|
1272 | - $this->checkout->current_step->reg_form->submission_error_message(), |
|
1273 | - __FILE__, |
|
1274 | - __FUNCTION__, |
|
1275 | - __LINE__ |
|
1276 | - ); |
|
1277 | - } |
|
1278 | - // well not really... what will happen is |
|
1279 | - // we'll just get redirected back to redo the current step |
|
1280 | - $this->go_to_next_step(); |
|
1281 | - return false; |
|
1282 | - } |
|
1283 | - } |
|
1284 | - } catch (EE_Error $e) { |
|
1285 | - $e->get_error(); |
|
1286 | - } |
|
1287 | - } |
|
1288 | - return true; |
|
1289 | - } |
|
1290 | - |
|
1291 | - |
|
1292 | - /** |
|
1293 | - * _process_action |
|
1294 | - * |
|
1295 | - * @return void |
|
1296 | - * @throws EE_Error |
|
1297 | - * @throws ReflectionException |
|
1298 | - */ |
|
1299 | - private function _process_form_action() |
|
1300 | - { |
|
1301 | - // what cha wanna do? |
|
1302 | - switch ($this->checkout->action) { |
|
1303 | - // AJAX next step reg form |
|
1304 | - case 'display_spco_reg_step': |
|
1305 | - $this->checkout->redirect = false; |
|
1306 | - if ($this->request->isAjax()) { |
|
1307 | - $this->checkout->json_response->set_reg_step_html( |
|
1308 | - $this->checkout->current_step->display_reg_form() |
|
1309 | - ); |
|
1310 | - } |
|
1311 | - break; |
|
1312 | - default: |
|
1313 | - // meh... do one of those other steps first |
|
1314 | - if ( |
|
1315 | - ! empty($this->checkout->action) |
|
1316 | - && is_callable(array($this->checkout->current_step, $this->checkout->action)) |
|
1317 | - ) { |
|
1318 | - // dynamically creates hook point like: |
|
1319 | - // AHEE__Single_Page_Checkout__before_attendee_information__process_reg_step |
|
1320 | - do_action( |
|
1321 | - "AHEE__Single_Page_Checkout__before_{$this->checkout->current_step->slug()}__{$this->checkout->action}", |
|
1322 | - $this->checkout->current_step |
|
1323 | - ); |
|
1324 | - $process_reg_step = apply_filters( |
|
1325 | - "AHEE__Single_Page_Checkout__process_reg_step__{$this->checkout->current_step->slug()}__{$this->checkout->action}", |
|
1326 | - true, |
|
1327 | - $this->checkout->current_step, |
|
1328 | - $this |
|
1329 | - ); |
|
1330 | - // call action on current step |
|
1331 | - if ($process_reg_step && call_user_func([$this->checkout->current_step, $this->checkout->action])) { |
|
1332 | - // good registrant, you get to proceed |
|
1333 | - if ( |
|
1334 | - $this->checkout->current_step->success_message() !== '' |
|
1335 | - && apply_filters( |
|
1336 | - 'FHEE__Single_Page_Checkout___process_form_action__display_success', |
|
1337 | - false |
|
1338 | - ) |
|
1339 | - ) { |
|
1340 | - EE_Error::add_success( |
|
1341 | - $this->checkout->current_step->success_message() |
|
1342 | - . '<br />' . $this->checkout->next_step->_instructions() |
|
1343 | - ); |
|
1344 | - } |
|
1345 | - // pack it up, pack it in... |
|
1346 | - $this->_setup_redirect(); |
|
1347 | - } |
|
1348 | - // dynamically creates hook point like: |
|
1349 | - // AHEE__Single_Page_Checkout__after_payment_options__process_reg_step |
|
1350 | - do_action( |
|
1351 | - "AHEE__Single_Page_Checkout__after_{$this->checkout->current_step->slug()}__{$this->checkout->action}", |
|
1352 | - $this->checkout->current_step |
|
1353 | - ); |
|
1354 | - } else { |
|
1355 | - EE_Error::add_error( |
|
1356 | - sprintf( |
|
1357 | - esc_html__( |
|
1358 | - 'The requested form action "%s" does not exist for the current "%s" registration step.', |
|
1359 | - 'event_espresso' |
|
1360 | - ), |
|
1361 | - $this->checkout->action, |
|
1362 | - $this->checkout->current_step->name() |
|
1363 | - ), |
|
1364 | - __FILE__, |
|
1365 | - __FUNCTION__, |
|
1366 | - __LINE__ |
|
1367 | - ); |
|
1368 | - } |
|
1369 | - // end default |
|
1370 | - } |
|
1371 | - // store our progress so far |
|
1372 | - $this->checkout->stash_transaction_and_checkout(); |
|
1373 | - // advance to the next step! If you pass GO, collect $200 |
|
1374 | - $this->go_to_next_step(); |
|
1375 | - } |
|
1376 | - |
|
1377 | - |
|
1378 | - /** |
|
1379 | - * @param EED_Single_Page_Checkout|EE_SPCO_Reg_Step $target an object with the method `translate_js_strings` and |
|
1380 | - * `enqueue_styles_and_scripts`. |
|
1381 | - * @return void |
|
1382 | - */ |
|
1383 | - public function add_styles_and_scripts($target) |
|
1384 | - { |
|
1385 | - // i18n |
|
1386 | - $target->translate_js_strings(); |
|
1387 | - if ($this->checkout->admin_request) { |
|
1388 | - add_action('admin_enqueue_scripts', array($target, 'enqueue_styles_and_scripts'), 10); |
|
1389 | - } else { |
|
1390 | - add_action('wp_enqueue_scripts', array($target, 'enqueue_styles_and_scripts'), 10); |
|
1391 | - } |
|
1392 | - } |
|
1393 | - |
|
1394 | - /** |
|
1395 | - * translate_js_strings |
|
1396 | - * |
|
1397 | - * @return void |
|
1398 | - */ |
|
1399 | - public function translate_js_strings() |
|
1400 | - { |
|
1401 | - EE_Registry::$i18n_js_strings['revisit'] = $this->checkout->revisit; |
|
1402 | - EE_Registry::$i18n_js_strings['e_reg_url_link'] = $this->checkout->reg_url_link; |
|
1403 | - EE_Registry::$i18n_js_strings['server_error'] = esc_html__( |
|
1404 | - 'An unknown error occurred on the server while attempting to process your request. Please refresh the page and try again or contact support.', |
|
1405 | - 'event_espresso' |
|
1406 | - ); |
|
1407 | - EE_Registry::$i18n_js_strings['invalid_json_response'] = esc_html__( |
|
1408 | - 'An invalid response was returned from the server while attempting to process your request. Please refresh the page and try again or contact support.', |
|
1409 | - 'event_espresso' |
|
1410 | - ); |
|
1411 | - EE_Registry::$i18n_js_strings['validation_error'] = esc_html__( |
|
1412 | - 'There appears to be a problem with the form validation configuration! Please check the admin settings or contact support.', |
|
1413 | - 'event_espresso' |
|
1414 | - ); |
|
1415 | - EE_Registry::$i18n_js_strings['invalid_payment_method'] = esc_html__( |
|
1416 | - 'There appears to be a problem with the payment method configuration! Please refresh the page and try again or contact support.', |
|
1417 | - 'event_espresso' |
|
1418 | - ); |
|
1419 | - EE_Registry::$i18n_js_strings['reg_step_error'] = esc_html__( |
|
1420 | - 'This registration step could not be completed. Please refresh the page and try again.', |
|
1421 | - 'event_espresso' |
|
1422 | - ); |
|
1423 | - EE_Registry::$i18n_js_strings['invalid_coupon'] = esc_html__( |
|
1424 | - 'We\'re sorry but that coupon code does not appear to be valid. If this is incorrect, please contact the site administrator.', |
|
1425 | - 'event_espresso' |
|
1426 | - ); |
|
1427 | - EE_Registry::$i18n_js_strings['process_registration'] = sprintf( |
|
1428 | - esc_html__( |
|
1429 | - 'Please wait while we process your registration.%sDo not refresh the page or navigate away while this is happening.%sThank you for your patience.', |
|
1430 | - 'event_espresso' |
|
1431 | - ), |
|
1432 | - '<br/>', |
|
1433 | - '<br/>' |
|
1434 | - ); |
|
1435 | - EE_Registry::$i18n_js_strings['language'] = get_bloginfo('language'); |
|
1436 | - EE_Registry::$i18n_js_strings['EESID'] = EE_Registry::instance()->SSN->id(); |
|
1437 | - EE_Registry::$i18n_js_strings['currency'] = EE_Registry::instance()->CFG->currency; |
|
1438 | - EE_Registry::$i18n_js_strings['datepicker_yearRange'] = '-150:+20'; |
|
1439 | - EE_Registry::$i18n_js_strings['timer_years'] = esc_html__('years', 'event_espresso'); |
|
1440 | - EE_Registry::$i18n_js_strings['timer_months'] = esc_html__('months', 'event_espresso'); |
|
1441 | - EE_Registry::$i18n_js_strings['timer_weeks'] = esc_html__('weeks', 'event_espresso'); |
|
1442 | - EE_Registry::$i18n_js_strings['timer_days'] = esc_html__('days', 'event_espresso'); |
|
1443 | - EE_Registry::$i18n_js_strings['timer_hours'] = esc_html__('hours', 'event_espresso'); |
|
1444 | - EE_Registry::$i18n_js_strings['timer_minutes'] = esc_html__('minutes', 'event_espresso'); |
|
1445 | - EE_Registry::$i18n_js_strings['timer_seconds'] = esc_html__('seconds', 'event_espresso'); |
|
1446 | - EE_Registry::$i18n_js_strings['timer_year'] = esc_html__('year', 'event_espresso'); |
|
1447 | - EE_Registry::$i18n_js_strings['timer_month'] = esc_html__('month', 'event_espresso'); |
|
1448 | - EE_Registry::$i18n_js_strings['timer_week'] = esc_html__('week', 'event_espresso'); |
|
1449 | - EE_Registry::$i18n_js_strings['timer_day'] = esc_html__('day', 'event_espresso'); |
|
1450 | - EE_Registry::$i18n_js_strings['timer_hour'] = esc_html__('hour', 'event_espresso'); |
|
1451 | - EE_Registry::$i18n_js_strings['timer_minute'] = esc_html__('minute', 'event_espresso'); |
|
1452 | - EE_Registry::$i18n_js_strings['timer_second'] = esc_html__('second', 'event_espresso'); |
|
1453 | - EE_Registry::$i18n_js_strings['registration_expiration_notice'] = EED_Single_Page_Checkout::getRegistrationExpirationNotice( |
|
1454 | - ); |
|
1455 | - EE_Registry::$i18n_js_strings['ajax_submit'] = apply_filters( |
|
1456 | - 'FHEE__Single_Page_Checkout__translate_js_strings__ajax_submit', |
|
1457 | - true |
|
1458 | - ); |
|
1459 | - EE_Registry::$i18n_js_strings['session_extension'] = absint( |
|
1460 | - apply_filters('FHEE__EE_Session__extend_expiration__seconds_added', 10 * MINUTE_IN_SECONDS) |
|
1461 | - ); |
|
1462 | - EE_Registry::$i18n_js_strings['session_expiration'] = gmdate( |
|
1463 | - 'M d, Y H:i:s', |
|
1464 | - EE_Registry::instance()->SSN->expiration() + (get_option('gmt_offset') * HOUR_IN_SECONDS) |
|
1465 | - ); |
|
1466 | - } |
|
1467 | - |
|
1468 | - |
|
1469 | - /** |
|
1470 | - * enqueue_styles_and_scripts |
|
1471 | - * |
|
1472 | - * @return void |
|
1473 | - * @throws EE_Error |
|
1474 | - */ |
|
1475 | - public function enqueue_styles_and_scripts() |
|
1476 | - { |
|
1477 | - // load css |
|
1478 | - wp_register_style( |
|
1479 | - 'single_page_checkout', |
|
1480 | - SPCO_CSS_URL . 'single_page_checkout.css', |
|
1481 | - array('espresso_default'), |
|
1482 | - EVENT_ESPRESSO_VERSION |
|
1483 | - ); |
|
1484 | - wp_enqueue_style('single_page_checkout'); |
|
1485 | - // load JS |
|
1486 | - wp_register_script( |
|
1487 | - 'jquery_plugin', |
|
1488 | - EE_GLOBAL_ASSETS_URL . 'scripts/jquery.plugin.min.js', |
|
1489 | - array('jquery'), |
|
1490 | - '1.0.1', |
|
1491 | - true |
|
1492 | - ); |
|
1493 | - wp_register_script( |
|
1494 | - 'jquery_countdown', |
|
1495 | - EE_GLOBAL_ASSETS_URL . 'scripts/jquery.countdown.min.js', |
|
1496 | - array('jquery_plugin'), |
|
1497 | - '2.1.0', |
|
1498 | - true |
|
1499 | - ); |
|
1500 | - wp_register_script( |
|
1501 | - 'single_page_checkout', |
|
1502 | - SPCO_JS_URL . 'single_page_checkout.js', |
|
1503 | - array('espresso_core', 'underscore', 'ee_form_section_validation'), |
|
1504 | - EVENT_ESPRESSO_VERSION, |
|
1505 | - true |
|
1506 | - ); |
|
1507 | - if ($this->checkout->registration_form instanceof EE_Form_Section_Proper) { |
|
1508 | - $this->checkout->registration_form->enqueue_js(); |
|
1509 | - } |
|
1510 | - if ($this->checkout->current_step->reg_form instanceof EE_Form_Section_Proper) { |
|
1511 | - $this->checkout->current_step->reg_form->enqueue_js(); |
|
1512 | - } |
|
1513 | - wp_enqueue_script('single_page_checkout'); |
|
1514 | - if (apply_filters('FHEE__registration_page_wrapper_template__display_time_limit', false)) { |
|
1515 | - wp_enqueue_script('jquery_countdown'); |
|
1516 | - } |
|
1517 | - /** |
|
1518 | - * global action hook for enqueueing styles and scripts with |
|
1519 | - * spco calls. |
|
1520 | - */ |
|
1521 | - do_action('AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts', $this); |
|
1522 | - /** |
|
1523 | - * dynamic action hook for enqueueing styles and scripts with spco calls. |
|
1524 | - * The hook will end up being something like: |
|
1525 | - * AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__attendee_information |
|
1526 | - */ |
|
1527 | - do_action( |
|
1528 | - 'AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__' . $this->checkout->current_step->slug(), |
|
1529 | - $this |
|
1530 | - ); |
|
1531 | - } |
|
1532 | - |
|
1533 | - |
|
1534 | - /** |
|
1535 | - * display the Registration Single Page Checkout Form |
|
1536 | - * |
|
1537 | - * @return void |
|
1538 | - * @throws EE_Error |
|
1539 | - * @throws ReflectionException |
|
1540 | - */ |
|
1541 | - private function _display_spco_reg_form() |
|
1542 | - { |
|
1543 | - // if registering via the admin, just display the reg form for the current step |
|
1544 | - if ($this->checkout->admin_request) { |
|
1545 | - EED_Single_Page_Checkout::getResponse()->addOutput($this->checkout->current_step->display_reg_form()); |
|
1546 | - } else { |
|
1547 | - // add powered by EE msg |
|
1548 | - add_action('AHEE__SPCO__reg_form_footer', array('EED_Single_Page_Checkout', 'display_registration_footer')); |
|
1549 | - $empty_cart = count( |
|
1550 | - $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params) |
|
1551 | - ) < 1; |
|
1552 | - EE_Registry::$i18n_js_strings['empty_cart'] = $empty_cart; |
|
1553 | - $cookies_not_set_msg = ''; |
|
1554 | - if ($empty_cart) { |
|
1555 | - $cookies_not_set_msg = apply_filters( |
|
1556 | - 'FHEE__Single_Page_Checkout__display_spco_reg_form__cookies_not_set_msg', |
|
1557 | - sprintf( |
|
1558 | - esc_html__( |
|
1559 | - '%1$s%3$sIt appears your browser is not currently set to accept Cookies%4$s%5$sIn order to register for events, you need to enable cookies.%7$sIf you require assistance, then click the following link to learn how to %8$senable cookies%9$s%6$s%2$s', |
|
1560 | - 'event_espresso' |
|
1561 | - ), |
|
1562 | - '<div class="ee-attention hidden" id="ee-cookies-not-set-msg">', |
|
1563 | - '</div>', |
|
1564 | - '<h6 class="important-notice">', |
|
1565 | - '</h6>', |
|
1566 | - '<p>', |
|
1567 | - '</p>', |
|
1568 | - '<br />', |
|
1569 | - '<a href="https://www.whatismybrowser.com/guides/how-to-enable-cookies/" target="_blank" rel="noopener noreferrer">', |
|
1570 | - '</a>' |
|
1571 | - ) |
|
1572 | - ); |
|
1573 | - } |
|
1574 | - $this->checkout->registration_form = new EE_Form_Section_Proper( |
|
1575 | - array( |
|
1576 | - 'name' => 'single-page-checkout', |
|
1577 | - 'html_id' => 'ee-single-page-checkout-dv', |
|
1578 | - 'layout_strategy' => |
|
1579 | - new EE_Template_Layout( |
|
1580 | - array( |
|
1581 | - 'layout_template_file' => SPCO_TEMPLATES_PATH . 'registration_page_wrapper.template.php', |
|
1582 | - 'template_args' => array( |
|
1583 | - 'empty_cart' => $empty_cart, |
|
1584 | - 'revisit' => $this->checkout->revisit, |
|
1585 | - 'reg_steps' => $this->checkout->reg_steps, |
|
1586 | - 'next_step' => $this->checkout->next_step instanceof EE_SPCO_Reg_Step |
|
1587 | - ? $this->checkout->next_step->slug() |
|
1588 | - : '', |
|
1589 | - 'empty_msg' => apply_filters( |
|
1590 | - 'FHEE__Single_Page_Checkout__display_spco_reg_form__empty_msg', |
|
1591 | - sprintf( |
|
1592 | - esc_html__( |
|
1593 | - 'You need to %1$sReturn to Events list%2$sselect at least one event%3$s before you can proceed with the registration process.', |
|
1594 | - 'event_espresso' |
|
1595 | - ), |
|
1596 | - '<a href="' |
|
1597 | - . get_post_type_archive_link('espresso_events') |
|
1598 | - . '" title="', |
|
1599 | - '">', |
|
1600 | - '</a>' |
|
1601 | - ) |
|
1602 | - ), |
|
1603 | - 'cookies_not_set_msg' => $cookies_not_set_msg, |
|
1604 | - 'registration_time_limit' => $this->checkout->get_registration_time_limit(), |
|
1605 | - 'session_expiration' => gmdate( |
|
1606 | - 'M d, Y H:i:s', |
|
1607 | - EE_Registry::instance()->SSN->expiration() |
|
1608 | - + (get_option('gmt_offset') * HOUR_IN_SECONDS) |
|
1609 | - ), |
|
1610 | - ), |
|
1611 | - ) |
|
1612 | - ), |
|
1613 | - ) |
|
1614 | - ); |
|
1615 | - // load template and add to output sent that gets filtered into the_content() |
|
1616 | - EED_Single_Page_Checkout::getResponse()->addOutput($this->checkout->registration_form->get_html()); |
|
1617 | - } |
|
1618 | - } |
|
1619 | - |
|
1620 | - |
|
1621 | - /** |
|
1622 | - * add_extra_finalize_registration_inputs |
|
1623 | - * |
|
1624 | - * @param $next_step |
|
1625 | - * @internal param string $label |
|
1626 | - * @return void |
|
1627 | - */ |
|
1628 | - public function add_extra_finalize_registration_inputs($next_step) |
|
1629 | - { |
|
1630 | - if ($next_step === 'finalize_registration') { |
|
1631 | - echo '<div id="spco-extra-finalize_registration-inputs-dv"></div>'; |
|
1632 | - } |
|
1633 | - } |
|
1634 | - |
|
1635 | - |
|
1636 | - /** |
|
1637 | - * display_registration_footer |
|
1638 | - * |
|
1639 | - * @return string |
|
1640 | - */ |
|
1641 | - public static function display_registration_footer() |
|
1642 | - { |
|
1643 | - if ( |
|
1644 | - apply_filters( |
|
1645 | - 'FHEE__EE_Front__Controller__show_reg_footer', |
|
1646 | - EE_Registry::instance()->CFG->admin->show_reg_footer |
|
1647 | - ) |
|
1648 | - ) { |
|
1649 | - add_filter( |
|
1650 | - 'FHEE__EEH_Template__powered_by_event_espresso__url', |
|
1651 | - function ($url) { |
|
1652 | - return apply_filters('FHEE__EE_Front_Controller__registration_footer__url', $url); |
|
1653 | - } |
|
1654 | - ); |
|
1655 | - echo apply_filters( |
|
1656 | - 'FHEE__EE_Front_Controller__display_registration_footer', |
|
1657 | - EEH_Template::powered_by_event_espresso( |
|
1658 | - '', |
|
1659 | - 'espresso-registration-footer-dv', |
|
1660 | - array('utm_content' => 'registration_checkout') |
|
1661 | - ) |
|
1662 | - ); |
|
1663 | - } |
|
1664 | - return ''; |
|
1665 | - } |
|
1666 | - |
|
1667 | - |
|
1668 | - /** |
|
1669 | - * unlock_transaction |
|
1670 | - * |
|
1671 | - * @return void |
|
1672 | - * @throws EE_Error |
|
1673 | - * @throws ReflectionException |
|
1674 | - */ |
|
1675 | - public function unlock_transaction() |
|
1676 | - { |
|
1677 | - if ($this->checkout->transaction instanceof EE_Transaction) { |
|
1678 | - $this->checkout->transaction->unlock(); |
|
1679 | - } |
|
1680 | - } |
|
1681 | - |
|
1682 | - |
|
1683 | - /** |
|
1684 | - * _setup_redirect |
|
1685 | - * |
|
1686 | - * @return void |
|
1687 | - */ |
|
1688 | - private function _setup_redirect() |
|
1689 | - { |
|
1690 | - if ($this->checkout->continue_reg && $this->checkout->next_step instanceof EE_SPCO_Reg_Step) { |
|
1691 | - $this->checkout->redirect = true; |
|
1692 | - if (empty($this->checkout->redirect_url)) { |
|
1693 | - $this->checkout->redirect_url = $this->checkout->next_step->reg_step_url(); |
|
1694 | - } |
|
1695 | - $this->checkout->redirect_url = apply_filters( |
|
1696 | - 'FHEE__EED_Single_Page_Checkout___setup_redirect__checkout_redirect_url', |
|
1697 | - $this->checkout->redirect_url, |
|
1698 | - $this->checkout |
|
1699 | - ); |
|
1700 | - } |
|
1701 | - } |
|
1702 | - |
|
1703 | - |
|
1704 | - /** |
|
1705 | - * handle ajax message responses and redirects |
|
1706 | - * |
|
1707 | - * @return void |
|
1708 | - * @throws EE_Error |
|
1709 | - * @throws ReflectionException |
|
1710 | - */ |
|
1711 | - public function go_to_next_step() |
|
1712 | - { |
|
1713 | - if ($this->request->isAjax()) { |
|
1714 | - // capture contents of output buffer we started earlier in the request, and insert into JSON response |
|
1715 | - $this->checkout->json_response->set_unexpected_errors(ob_get_clean()); |
|
1716 | - } |
|
1717 | - $this->unlock_transaction(); |
|
1718 | - // just return for these conditions |
|
1719 | - if ( |
|
1720 | - $this->checkout->admin_request |
|
1721 | - || $this->checkout->action === 'redirect_form' |
|
1722 | - || $this->checkout->action === 'update_checkout' |
|
1723 | - ) { |
|
1724 | - return; |
|
1725 | - } |
|
1726 | - // AJAX response |
|
1727 | - $this->_handle_json_response(); |
|
1728 | - // redirect to next step or the Thank You page |
|
1729 | - $this->_handle_html_redirects(); |
|
1730 | - // hmmm... must be something wrong, so let's just display the form again ! |
|
1731 | - $this->_display_spco_reg_form(); |
|
1732 | - } |
|
1733 | - |
|
1734 | - |
|
1735 | - /** |
|
1736 | - * _handle_json_response |
|
1737 | - * |
|
1738 | - * @return void |
|
1739 | - * @throws EE_Error |
|
1740 | - */ |
|
1741 | - protected function _handle_json_response() |
|
1742 | - { |
|
1743 | - // if this is an ajax request |
|
1744 | - if ($this->request->isAjax()) { |
|
1745 | - $this->checkout->json_response->set_registration_time_limit( |
|
1746 | - $this->checkout->get_registration_time_limit() |
|
1747 | - ); |
|
1748 | - $this->checkout->json_response->set_payment_amount($this->checkout->amount_owing); |
|
1749 | - // just send the ajax ( |
|
1750 | - $json_response = apply_filters( |
|
1751 | - 'FHEE__EE_Single_Page_Checkout__JSON_response', |
|
1752 | - $this->checkout->json_response |
|
1753 | - ); |
|
1754 | - exit($json_response); |
|
1755 | - } |
|
1756 | - } |
|
1757 | - |
|
1758 | - |
|
1759 | - /** |
|
1760 | - * _handle_redirects |
|
1761 | - * |
|
1762 | - * @return void |
|
1763 | - */ |
|
1764 | - protected function _handle_html_redirects() |
|
1765 | - { |
|
1766 | - // going somewhere ? |
|
1767 | - if ($this->checkout->redirect && ! empty($this->checkout->redirect_url)) { |
|
1768 | - // store notices in a transient |
|
1769 | - EE_Error::get_notices(false, true); |
|
1770 | - wp_safe_redirect($this->checkout->redirect_url); |
|
1771 | - exit(); |
|
1772 | - } |
|
1773 | - } |
|
1774 | - |
|
1775 | - |
|
1776 | - /** |
|
1777 | - * set_checkout_anchor |
|
1778 | - * |
|
1779 | - * @return void |
|
1780 | - */ |
|
1781 | - public function set_checkout_anchor() |
|
1782 | - { |
|
1783 | - echo '<a id="checkout" style="float: left; margin-left: -999em;"></a>'; |
|
1784 | - } |
|
1785 | - |
|
1786 | - /** |
|
1787 | - * getRegistrationExpirationNotice |
|
1788 | - * |
|
1789 | - * @since 4.9.59.p |
|
1790 | - * @return string |
|
1791 | - */ |
|
1792 | - public static function getRegistrationExpirationNotice() |
|
1793 | - { |
|
1794 | - return sprintf( |
|
1795 | - esc_html__( |
|
1796 | - '%1$sWe\'re sorry, but your registration time has expired.%2$s%3$s%4$sIf you still wish to complete your registration, please return to the %5$sEvent List%6$sEvent List%7$s and reselect your tickets if available. Please accept our apologies for any inconvenience this may have caused.%8$s', |
|
1797 | - 'event_espresso' |
|
1798 | - ), |
|
1799 | - '<h4 class="important-notice">', |
|
1800 | - '</h4>', |
|
1801 | - '<br />', |
|
1802 | - '<p>', |
|
1803 | - '<a href="' . get_post_type_archive_link('espresso_events') . '" title="', |
|
1804 | - '">', |
|
1805 | - '</a>', |
|
1806 | - '</p>' |
|
1807 | - ); |
|
1808 | - } |
|
22 | + /** |
|
23 | + * $_initialized - has the SPCO controller already been initialized ? |
|
24 | + * |
|
25 | + * @var bool $_initialized |
|
26 | + */ |
|
27 | + private static $_initialized = false; |
|
28 | + |
|
29 | + |
|
30 | + /** |
|
31 | + * $_checkout_verified - is the EE_Checkout verified as correct for this request ? |
|
32 | + * |
|
33 | + * @var bool $_valid_checkout |
|
34 | + */ |
|
35 | + private static $_checkout_verified = true; |
|
36 | + |
|
37 | + /** |
|
38 | + * $_reg_steps_array - holds initial array of reg steps |
|
39 | + * |
|
40 | + * @var array $_reg_steps_array |
|
41 | + */ |
|
42 | + private static $_reg_steps_array = array(); |
|
43 | + |
|
44 | + /** |
|
45 | + * $checkout - EE_Checkout object for handling the properties of the current checkout process |
|
46 | + * |
|
47 | + * @var EE_Checkout $checkout |
|
48 | + */ |
|
49 | + public $checkout; |
|
50 | + |
|
51 | + /** |
|
52 | + * @var RequestInterface $request |
|
53 | + */ |
|
54 | + protected $request; |
|
55 | + |
|
56 | + |
|
57 | + /** |
|
58 | + * @return EED_Single_Page_Checkout|EED_Module |
|
59 | + * @throws EE_Error |
|
60 | + * @throws ReflectionException |
|
61 | + */ |
|
62 | + public static function instance() |
|
63 | + { |
|
64 | + add_filter('EED_Single_Page_Checkout__SPCO_active', '__return_true'); |
|
65 | + return parent::get_instance(__CLASS__); |
|
66 | + } |
|
67 | + |
|
68 | + |
|
69 | + /** |
|
70 | + * @return EE_CART |
|
71 | + */ |
|
72 | + public function cart() |
|
73 | + { |
|
74 | + return $this->checkout->cart; |
|
75 | + } |
|
76 | + |
|
77 | + |
|
78 | + /** |
|
79 | + * @return RequestInterface |
|
80 | + * @since 4.10.14.p |
|
81 | + */ |
|
82 | + public static function getRequest() |
|
83 | + { |
|
84 | + return LoaderFactory::getLoader()->getShared(RequestInterface::class); |
|
85 | + } |
|
86 | + |
|
87 | + |
|
88 | + /** |
|
89 | + * @return EE_Transaction |
|
90 | + */ |
|
91 | + public function transaction() |
|
92 | + { |
|
93 | + return $this->checkout->transaction; |
|
94 | + } |
|
95 | + |
|
96 | + |
|
97 | + /** |
|
98 | + * set_hooks - for hooking into EE Core, other modules, etc |
|
99 | + * |
|
100 | + * @return void |
|
101 | + * @throws EE_Error |
|
102 | + */ |
|
103 | + public static function set_hooks() |
|
104 | + { |
|
105 | + EED_Single_Page_Checkout::set_definitions(); |
|
106 | + } |
|
107 | + |
|
108 | + |
|
109 | + /** |
|
110 | + * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
111 | + * |
|
112 | + * @return void |
|
113 | + * @throws EE_Error |
|
114 | + */ |
|
115 | + public static function set_hooks_admin() |
|
116 | + { |
|
117 | + EED_Single_Page_Checkout::set_definitions(); |
|
118 | + if (! (defined('DOING_AJAX') && DOING_AJAX)) { |
|
119 | + return; |
|
120 | + } |
|
121 | + // going to start an output buffer in case anything gets accidentally output |
|
122 | + // that might disrupt our JSON response |
|
123 | + ob_start(); |
|
124 | + EED_Single_Page_Checkout::load_reg_steps(); |
|
125 | + // set ajax hooks |
|
126 | + add_action('wp_ajax_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step')); |
|
127 | + add_action('wp_ajax_nopriv_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step')); |
|
128 | + add_action('wp_ajax_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step')); |
|
129 | + add_action('wp_ajax_nopriv_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step')); |
|
130 | + add_action('wp_ajax_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step')); |
|
131 | + add_action('wp_ajax_nopriv_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step')); |
|
132 | + } |
|
133 | + |
|
134 | + |
|
135 | + /** |
|
136 | + * process ajax request |
|
137 | + * |
|
138 | + * @param string $ajax_action |
|
139 | + * @throws EE_Error |
|
140 | + * @throws ReflectionException |
|
141 | + */ |
|
142 | + public static function process_ajax_request($ajax_action) |
|
143 | + { |
|
144 | + $request = EED_Single_Page_Checkout::getRequest(); |
|
145 | + $request->setRequestParam('action', $ajax_action); |
|
146 | + EED_Single_Page_Checkout::instance()->_initialize(); |
|
147 | + } |
|
148 | + |
|
149 | + |
|
150 | + /** |
|
151 | + * ajax display registration step |
|
152 | + * |
|
153 | + * @throws EE_Error |
|
154 | + * @throws ReflectionException |
|
155 | + */ |
|
156 | + public static function display_reg_step() |
|
157 | + { |
|
158 | + EED_Single_Page_Checkout::process_ajax_request('display_spco_reg_step'); |
|
159 | + } |
|
160 | + |
|
161 | + |
|
162 | + /** |
|
163 | + * ajax process registration step |
|
164 | + * |
|
165 | + * @throws EE_Error |
|
166 | + * @throws ReflectionException |
|
167 | + */ |
|
168 | + public static function process_reg_step() |
|
169 | + { |
|
170 | + EED_Single_Page_Checkout::process_ajax_request('process_reg_step'); |
|
171 | + } |
|
172 | + |
|
173 | + |
|
174 | + /** |
|
175 | + * ajax process registration step |
|
176 | + * |
|
177 | + * @throws EE_Error |
|
178 | + * @throws ReflectionException |
|
179 | + */ |
|
180 | + public static function update_reg_step() |
|
181 | + { |
|
182 | + EED_Single_Page_Checkout::process_ajax_request('update_reg_step'); |
|
183 | + } |
|
184 | + |
|
185 | + |
|
186 | + /** |
|
187 | + * update_checkout |
|
188 | + * |
|
189 | + * @return void |
|
190 | + * @throws ReflectionException |
|
191 | + * @throws EE_Error |
|
192 | + */ |
|
193 | + public static function update_checkout() |
|
194 | + { |
|
195 | + EED_Single_Page_Checkout::process_ajax_request('update_checkout'); |
|
196 | + } |
|
197 | + |
|
198 | + |
|
199 | + /** |
|
200 | + * @return void |
|
201 | + * @deprecated 4.10.14.p |
|
202 | + */ |
|
203 | + public static function load_request_handler() |
|
204 | + { |
|
205 | + } |
|
206 | + |
|
207 | + |
|
208 | + /** |
|
209 | + * set_definitions |
|
210 | + * |
|
211 | + * @return void |
|
212 | + * @throws EE_Error |
|
213 | + */ |
|
214 | + public static function set_definitions() |
|
215 | + { |
|
216 | + if (defined('SPCO_BASE_PATH')) { |
|
217 | + return; |
|
218 | + } |
|
219 | + define( |
|
220 | + 'SPCO_BASE_PATH', |
|
221 | + rtrim(str_replace(array('\\', '/'), '/', plugin_dir_path(__FILE__)), '/') . '/' |
|
222 | + ); |
|
223 | + define('SPCO_CSS_URL', plugin_dir_url(__FILE__) . 'css/'); |
|
224 | + define('SPCO_IMG_URL', plugin_dir_url(__FILE__) . 'img/'); |
|
225 | + define('SPCO_JS_URL', plugin_dir_url(__FILE__) . 'js/'); |
|
226 | + define('SPCO_INC_PATH', SPCO_BASE_PATH . 'inc/'); |
|
227 | + define('SPCO_REG_STEPS_PATH', SPCO_BASE_PATH . 'reg_steps/'); |
|
228 | + define('SPCO_TEMPLATES_PATH', SPCO_BASE_PATH . 'templates/'); |
|
229 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(SPCO_BASE_PATH, true); |
|
230 | + EE_Registry::$i18n_js_strings['registration_expiration_notice'] = EED_Single_Page_Checkout::getRegistrationExpirationNotice( |
|
231 | + ); |
|
232 | + } |
|
233 | + |
|
234 | + |
|
235 | + /** |
|
236 | + * load_reg_steps |
|
237 | + * loads and instantiates each reg step based on the EE_Registry::instance()->CFG->registration->reg_steps array |
|
238 | + * |
|
239 | + * @throws EE_Error |
|
240 | + */ |
|
241 | + public static function load_reg_steps() |
|
242 | + { |
|
243 | + static $reg_steps_loaded = false; |
|
244 | + if ($reg_steps_loaded) { |
|
245 | + return; |
|
246 | + } |
|
247 | + // filter list of reg_steps |
|
248 | + $reg_steps_to_load = (array) apply_filters( |
|
249 | + 'AHEE__SPCO__load_reg_steps__reg_steps_to_load', |
|
250 | + EED_Single_Page_Checkout::get_reg_steps() |
|
251 | + ); |
|
252 | + // sort by key (order) |
|
253 | + ksort($reg_steps_to_load); |
|
254 | + // loop through folders |
|
255 | + foreach ($reg_steps_to_load as $order => $reg_step) { |
|
256 | + // we need a |
|
257 | + if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) { |
|
258 | + // copy over to the reg_steps_array |
|
259 | + EED_Single_Page_Checkout::$_reg_steps_array[ $order ] = $reg_step; |
|
260 | + // register custom key route for each reg step |
|
261 | + // ie: step=>"slug" - this is the entire reason we load the reg steps array now |
|
262 | + EE_Config::register_route( |
|
263 | + $reg_step['slug'], |
|
264 | + 'EED_Single_Page_Checkout', |
|
265 | + 'run', |
|
266 | + 'step' |
|
267 | + ); |
|
268 | + // add AJAX or other hooks |
|
269 | + if (isset($reg_step['has_hooks']) && $reg_step['has_hooks']) { |
|
270 | + // setup autoloaders if necessary |
|
271 | + if (! class_exists($reg_step['class_name'])) { |
|
272 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder( |
|
273 | + $reg_step['file_path'], |
|
274 | + true |
|
275 | + ); |
|
276 | + } |
|
277 | + if (is_callable($reg_step['class_name'], 'set_hooks')) { |
|
278 | + call_user_func(array($reg_step['class_name'], 'set_hooks')); |
|
279 | + } |
|
280 | + } |
|
281 | + } |
|
282 | + } |
|
283 | + $reg_steps_loaded = true; |
|
284 | + } |
|
285 | + |
|
286 | + |
|
287 | + /** |
|
288 | + * get_reg_steps |
|
289 | + * |
|
290 | + * @return array |
|
291 | + */ |
|
292 | + public static function get_reg_steps() |
|
293 | + { |
|
294 | + $reg_steps = EE_Registry::instance()->CFG->registration->reg_steps; |
|
295 | + if (empty($reg_steps)) { |
|
296 | + $reg_steps = array( |
|
297 | + 10 => array( |
|
298 | + 'file_path' => SPCO_REG_STEPS_PATH . 'attendee_information', |
|
299 | + 'class_name' => 'EE_SPCO_Reg_Step_Attendee_Information', |
|
300 | + 'slug' => 'attendee_information', |
|
301 | + 'has_hooks' => false, |
|
302 | + ), |
|
303 | + 30 => array( |
|
304 | + 'file_path' => SPCO_REG_STEPS_PATH . 'payment_options', |
|
305 | + 'class_name' => 'EE_SPCO_Reg_Step_Payment_Options', |
|
306 | + 'slug' => 'payment_options', |
|
307 | + 'has_hooks' => true, |
|
308 | + ), |
|
309 | + 999 => array( |
|
310 | + 'file_path' => SPCO_REG_STEPS_PATH . 'finalize_registration', |
|
311 | + 'class_name' => 'EE_SPCO_Reg_Step_Finalize_Registration', |
|
312 | + 'slug' => 'finalize_registration', |
|
313 | + 'has_hooks' => false, |
|
314 | + ), |
|
315 | + ); |
|
316 | + } |
|
317 | + return $reg_steps; |
|
318 | + } |
|
319 | + |
|
320 | + |
|
321 | + /** |
|
322 | + * registration_checkout_for_admin |
|
323 | + * |
|
324 | + * @return string |
|
325 | + * @throws EE_Error |
|
326 | + * @throws ReflectionException |
|
327 | + */ |
|
328 | + public static function registration_checkout_for_admin() |
|
329 | + { |
|
330 | + $request = EED_Single_Page_Checkout::getRequest(); |
|
331 | + $request->setRequestParam('step', 'attendee_information'); |
|
332 | + $request->setRequestParam('action', 'display_spco_reg_step'); |
|
333 | + $request->setRequestParam('process_form_submission', false); |
|
334 | + EED_Single_Page_Checkout::instance()->_initialize(); |
|
335 | + EED_Single_Page_Checkout::instance()->_display_spco_reg_form(); |
|
336 | + return EED_Single_Page_Checkout::getResponse()->getOutput(); |
|
337 | + } |
|
338 | + |
|
339 | + |
|
340 | + /** |
|
341 | + * process_registration_from_admin |
|
342 | + * |
|
343 | + * @return EE_Transaction |
|
344 | + * @throws EE_Error |
|
345 | + * @throws ReflectionException |
|
346 | + */ |
|
347 | + public static function process_registration_from_admin() |
|
348 | + { |
|
349 | + $request = EED_Single_Page_Checkout::getRequest(); |
|
350 | + $request->setRequestParam('step', 'attendee_information'); |
|
351 | + $request->setRequestParam('action', 'process_reg_step'); |
|
352 | + $request->setRequestParam('process_form_submission', true); |
|
353 | + EED_Single_Page_Checkout::instance()->_initialize(); |
|
354 | + if (EED_Single_Page_Checkout::instance()->checkout->current_step->completed()) { |
|
355 | + $final_reg_step = end(EED_Single_Page_Checkout::instance()->checkout->reg_steps); |
|
356 | + if ($final_reg_step instanceof EE_SPCO_Reg_Step_Finalize_Registration) { |
|
357 | + EED_Single_Page_Checkout::instance()->checkout->set_reg_step_initiated($final_reg_step); |
|
358 | + if ($final_reg_step->process_reg_step()) { |
|
359 | + $final_reg_step->set_completed(); |
|
360 | + EED_Single_Page_Checkout::instance()->checkout->update_txn_reg_steps_array(); |
|
361 | + return EED_Single_Page_Checkout::instance()->checkout->transaction; |
|
362 | + } |
|
363 | + } |
|
364 | + } |
|
365 | + return null; |
|
366 | + } |
|
367 | + |
|
368 | + |
|
369 | + /** |
|
370 | + * run |
|
371 | + * |
|
372 | + * @param WP_Query $WP |
|
373 | + * @return void |
|
374 | + */ |
|
375 | + public function run($WP) |
|
376 | + { |
|
377 | + if ( |
|
378 | + $WP instanceof WP_Query |
|
379 | + && $WP->is_main_query() |
|
380 | + && apply_filters('FHEE__EED_Single_Page_Checkout__run', true) |
|
381 | + && $this->_is_reg_checkout() |
|
382 | + ) { |
|
383 | + $this->_initialize(); |
|
384 | + } |
|
385 | + } |
|
386 | + |
|
387 | + |
|
388 | + /** |
|
389 | + * determines whether current url matches reg page url |
|
390 | + * |
|
391 | + * @return bool |
|
392 | + */ |
|
393 | + protected function _is_reg_checkout() |
|
394 | + { |
|
395 | + // get current permalink for reg page without any extra query args |
|
396 | + $reg_page_url = get_permalink(EE_Config::instance()->core->reg_page_id); |
|
397 | + // get request URI for current request, but without the scheme or host |
|
398 | + $current_request_uri = EEH_URL::filter_input_server_url(); |
|
399 | + $current_request_uri = html_entity_decode($current_request_uri); |
|
400 | + // get array of query args from the current request URI |
|
401 | + $query_args = EEH_URL::get_query_string($current_request_uri); |
|
402 | + // grab page id if it is set |
|
403 | + $page_id = isset($query_args['page_id']) ? absint($query_args['page_id']) : 0; |
|
404 | + // and remove the page id from the query args (we will re-add it later) |
|
405 | + unset($query_args['page_id']); |
|
406 | + // now strip all query args from current request URI |
|
407 | + $current_request_uri = remove_query_arg(array_keys($query_args), $current_request_uri); |
|
408 | + // and re-add the page id if it was set |
|
409 | + if ($page_id) { |
|
410 | + $current_request_uri = add_query_arg('page_id', $page_id, $current_request_uri); |
|
411 | + } |
|
412 | + // remove slashes and ? |
|
413 | + $current_request_uri = trim($current_request_uri, '?/'); |
|
414 | + // is current request URI part of the known full reg page URL ? |
|
415 | + return ! empty($current_request_uri) && strpos($reg_page_url, $current_request_uri) !== false; |
|
416 | + } |
|
417 | + |
|
418 | + |
|
419 | + /** |
|
420 | + * @param WP_Query $wp_query |
|
421 | + * @return void |
|
422 | + * @throws EE_Error |
|
423 | + * @throws ReflectionException |
|
424 | + */ |
|
425 | + public static function init($wp_query) |
|
426 | + { |
|
427 | + EED_Single_Page_Checkout::instance()->run($wp_query); |
|
428 | + } |
|
429 | + |
|
430 | + |
|
431 | + /** |
|
432 | + * _initialize - initial module setup |
|
433 | + * |
|
434 | + * @return void |
|
435 | + */ |
|
436 | + private function _initialize() |
|
437 | + { |
|
438 | + // ensure SPCO doesn't run twice |
|
439 | + if (EED_Single_Page_Checkout::$_initialized) { |
|
440 | + return; |
|
441 | + } |
|
442 | + try { |
|
443 | + $this->request = EED_Single_Page_Checkout::getRequest(); |
|
444 | + EED_Single_Page_Checkout::load_reg_steps(); |
|
445 | + $this->_verify_session(); |
|
446 | + // setup the EE_Checkout object |
|
447 | + $this->checkout = $this->_initialize_checkout(); |
|
448 | + // filter checkout |
|
449 | + $this->checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize__checkout', $this->checkout); |
|
450 | + // get the $_GET |
|
451 | + $this->_get_request_vars(); |
|
452 | + if ($this->_block_bots()) { |
|
453 | + return; |
|
454 | + } |
|
455 | + // filter continue_reg |
|
456 | + $this->checkout->continue_reg = apply_filters( |
|
457 | + 'FHEE__EED_Single_Page_Checkout__init___continue_reg', |
|
458 | + true, |
|
459 | + $this->checkout |
|
460 | + ); |
|
461 | + // load the reg steps array |
|
462 | + if (! $this->_load_and_instantiate_reg_steps()) { |
|
463 | + EED_Single_Page_Checkout::$_initialized = true; |
|
464 | + return; |
|
465 | + } |
|
466 | + // set the current step |
|
467 | + $this->checkout->set_current_step($this->checkout->step); |
|
468 | + // and the next step |
|
469 | + $this->checkout->set_next_step(); |
|
470 | + // verify that everything has been setup correctly |
|
471 | + if (! ($this->_verify_transaction_and_get_registrations() && $this->_final_verifications())) { |
|
472 | + EED_Single_Page_Checkout::$_initialized = true; |
|
473 | + return; |
|
474 | + } |
|
475 | + // lock the transaction |
|
476 | + $this->checkout->transaction->lock(); |
|
477 | + // make sure all of our cached objects are added to their respective model entity mappers |
|
478 | + $this->checkout->refresh_all_entities(); |
|
479 | + // set amount owing |
|
480 | + $this->checkout->amount_owing = $this->checkout->transaction->remaining(); |
|
481 | + // initialize each reg step, which gives them the chance to potentially alter the process |
|
482 | + $this->_initialize_reg_steps(); |
|
483 | + // DEBUG LOG |
|
484 | + // $this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ ); |
|
485 | + // get reg form |
|
486 | + if (! $this->_check_form_submission()) { |
|
487 | + EED_Single_Page_Checkout::$_initialized = true; |
|
488 | + return; |
|
489 | + } |
|
490 | + // checkout the action!!! |
|
491 | + $this->_process_form_action(); |
|
492 | + // add some style and make it dance |
|
493 | + $this->add_styles_and_scripts($this); |
|
494 | + // kk... SPCO has successfully run |
|
495 | + EED_Single_Page_Checkout::$_initialized = true; |
|
496 | + // set no cache headers and constants |
|
497 | + EE_System::do_not_cache(); |
|
498 | + // add anchor |
|
499 | + add_action('loop_start', array($this, 'set_checkout_anchor'), 1); |
|
500 | + // remove transaction lock |
|
501 | + add_action('shutdown', array($this, 'unlock_transaction'), 1); |
|
502 | + } catch (Exception $e) { |
|
503 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
504 | + } |
|
505 | + } |
|
506 | + |
|
507 | + |
|
508 | + /** |
|
509 | + * _verify_session |
|
510 | + * checks that the session is valid and not expired |
|
511 | + * |
|
512 | + * @throws EE_Error |
|
513 | + * @throws ReflectionException |
|
514 | + */ |
|
515 | + private function _verify_session() |
|
516 | + { |
|
517 | + if (! EE_Registry::instance()->SSN instanceof EE_Session) { |
|
518 | + throw new EE_Error(esc_html__('The EE_Session class could not be loaded.', 'event_espresso')); |
|
519 | + } |
|
520 | + $clear_session_requested = $this->request->getRequestParam('clear_session', false, 'bool'); |
|
521 | + // is session still valid ? |
|
522 | + if ( |
|
523 | + $clear_session_requested |
|
524 | + || ( |
|
525 | + EE_Registry::instance()->SSN->expired() |
|
526 | + && $this->request->getRequestParam('e_reg_url_link') === '' |
|
527 | + ) |
|
528 | + ) { |
|
529 | + $this->checkout = new EE_Checkout(); |
|
530 | + EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
531 | + // EE_Registry::instance()->SSN->reset_cart(); |
|
532 | + // EE_Registry::instance()->SSN->reset_checkout(); |
|
533 | + // EE_Registry::instance()->SSN->reset_transaction(); |
|
534 | + if (! $clear_session_requested) { |
|
535 | + EE_Error::add_attention( |
|
536 | + EE_Registry::$i18n_js_strings['registration_expiration_notice'], |
|
537 | + __FILE__, |
|
538 | + __FUNCTION__, |
|
539 | + __LINE__ |
|
540 | + ); |
|
541 | + } |
|
542 | + // EE_Registry::instance()->SSN->reset_expired(); |
|
543 | + } |
|
544 | + } |
|
545 | + |
|
546 | + |
|
547 | + /** |
|
548 | + * _initialize_checkout |
|
549 | + * loads and instantiates EE_Checkout |
|
550 | + * |
|
551 | + * @return EE_Checkout |
|
552 | + * @throws EE_Error |
|
553 | + * @throws ReflectionException |
|
554 | + */ |
|
555 | + private function _initialize_checkout() |
|
556 | + { |
|
557 | + // look in session for existing checkout |
|
558 | + /** @type EE_Checkout $checkout */ |
|
559 | + $checkout = EE_Registry::instance()->SSN->checkout(); |
|
560 | + // verify |
|
561 | + if (! $checkout instanceof EE_Checkout) { |
|
562 | + // instantiate EE_Checkout object for handling the properties of the current checkout process |
|
563 | + $checkout = EE_Registry::instance()->load_file( |
|
564 | + SPCO_INC_PATH, |
|
565 | + 'EE_Checkout', |
|
566 | + 'class', |
|
567 | + array(), |
|
568 | + false |
|
569 | + ); |
|
570 | + } else { |
|
571 | + if ($checkout->current_step->is_final_step() && $checkout->exit_spco() === true) { |
|
572 | + $this->unlock_transaction(); |
|
573 | + wp_safe_redirect($checkout->redirect_url); |
|
574 | + exit(); |
|
575 | + } |
|
576 | + } |
|
577 | + $checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize_checkout__checkout', $checkout); |
|
578 | + // verify again |
|
579 | + if (! $checkout instanceof EE_Checkout) { |
|
580 | + throw new EE_Error(esc_html__('The EE_Checkout class could not be loaded.', 'event_espresso')); |
|
581 | + } |
|
582 | + // reset anything that needs a clean slate for each request |
|
583 | + $checkout->reset_for_current_request(); |
|
584 | + return $checkout; |
|
585 | + } |
|
586 | + |
|
587 | + |
|
588 | + /** |
|
589 | + * _get_request_vars |
|
590 | + * |
|
591 | + * @return void |
|
592 | + */ |
|
593 | + private function _get_request_vars() |
|
594 | + { |
|
595 | + // make sure this request is marked as belonging to EE |
|
596 | + /** @var CurrentPage $current_page */ |
|
597 | + $current_page = LoaderFactory::getLoader()->getShared(CurrentPage::class); |
|
598 | + $current_page->setEspressoPage(true); |
|
599 | + // which step is being requested ? |
|
600 | + $this->checkout->step = $this->request->getRequestParam('step', $this->_get_first_step()); |
|
601 | + // which step is being edited ? |
|
602 | + $this->checkout->edit_step = $this->request->getRequestParam('edit_step'); |
|
603 | + // and what we're doing on the current step |
|
604 | + $this->checkout->action = $this->request->getRequestParam('action', 'display_spco_reg_step'); |
|
605 | + // timestamp |
|
606 | + $this->checkout->uts = $this->request->getRequestParam('uts', 0, 'int'); |
|
607 | + // returning to edit ? |
|
608 | + $this->checkout->reg_url_link = $this->request->getRequestParam('e_reg_url_link'); |
|
609 | + // add reg url link to registration query params |
|
610 | + if ($this->checkout->reg_url_link && strpos($this->checkout->reg_url_link, '1-') !== 0) { |
|
611 | + $this->checkout->reg_cache_where_params[0]['REG_url_link'] = $this->checkout->reg_url_link; |
|
612 | + } |
|
613 | + // or some other kind of revisit ? |
|
614 | + $this->checkout->revisit = $this->request->getRequestParam('revisit', false, 'bool'); |
|
615 | + // and whether or not to generate a reg form for this request |
|
616 | + $this->checkout->generate_reg_form = $this->request->getRequestParam('generate_reg_form', true, 'bool'); |
|
617 | + // and whether or not to process a reg form submission for this request |
|
618 | + $this->checkout->process_form_submission = $this->request->getRequestParam( |
|
619 | + 'process_form_submission', |
|
620 | + $this->checkout->action === 'process_reg_step', |
|
621 | + 'bool' |
|
622 | + ); |
|
623 | + $this->checkout->process_form_submission = filter_var( |
|
624 | + $this->checkout->action !== 'display_spco_reg_step' |
|
625 | + ? $this->checkout->process_form_submission |
|
626 | + : false, |
|
627 | + FILTER_VALIDATE_BOOLEAN |
|
628 | + ); |
|
629 | + // $this->_display_request_vars(); |
|
630 | + } |
|
631 | + |
|
632 | + |
|
633 | + /** |
|
634 | + * _display_request_vars |
|
635 | + * |
|
636 | + * @return void |
|
637 | + */ |
|
638 | + protected function _display_request_vars() |
|
639 | + { |
|
640 | + if (! WP_DEBUG) { |
|
641 | + return; |
|
642 | + } |
|
643 | + EEH_Debug_Tools::printr($this->request->requestParams(), 'requestParams', __FILE__, __LINE__); |
|
644 | + EEH_Debug_Tools::printr($this->checkout->step, '$this->checkout->step', __FILE__, __LINE__); |
|
645 | + EEH_Debug_Tools::printr($this->checkout->edit_step, '$this->checkout->edit_step', __FILE__, __LINE__); |
|
646 | + EEH_Debug_Tools::printr($this->checkout->action, '$this->checkout->action', __FILE__, __LINE__); |
|
647 | + EEH_Debug_Tools::printr($this->checkout->reg_url_link, '$this->checkout->reg_url_link', __FILE__, __LINE__); |
|
648 | + EEH_Debug_Tools::printr($this->checkout->revisit, '$this->checkout->revisit', __FILE__, __LINE__); |
|
649 | + EEH_Debug_Tools::printr( |
|
650 | + $this->checkout->generate_reg_form, |
|
651 | + '$this->checkout->generate_reg_form', |
|
652 | + __FILE__, |
|
653 | + __LINE__ |
|
654 | + ); |
|
655 | + EEH_Debug_Tools::printr( |
|
656 | + $this->checkout->process_form_submission, |
|
657 | + '$this->checkout->process_form_submission', |
|
658 | + __FILE__, |
|
659 | + __LINE__ |
|
660 | + ); |
|
661 | + } |
|
662 | + |
|
663 | + |
|
664 | + /** |
|
665 | + * _block_bots |
|
666 | + * checks that the incoming request has either of the following set: |
|
667 | + * a uts (unix timestamp) which indicates that the request was redirected from the Ticket Selector |
|
668 | + * a REG URL Link, which indicates that the request is a return visit to SPCO for a valid TXN |
|
669 | + * so if you're not coming from the Ticket Selector nor returning for a valid IP... |
|
670 | + * then where you coming from man? |
|
671 | + * |
|
672 | + * @return boolean |
|
673 | + */ |
|
674 | + private function _block_bots() |
|
675 | + { |
|
676 | + $invalid_checkout_access = EED_Invalid_Checkout_Access::getInvalidCheckoutAccess(); |
|
677 | + if ($invalid_checkout_access->checkoutAccessIsInvalid($this->checkout)) { |
|
678 | + return true; |
|
679 | + } |
|
680 | + return false; |
|
681 | + } |
|
682 | + |
|
683 | + |
|
684 | + /** |
|
685 | + * _get_first_step |
|
686 | + * gets slug for first step in $_reg_steps_array |
|
687 | + * |
|
688 | + * @return string |
|
689 | + */ |
|
690 | + private function _get_first_step() |
|
691 | + { |
|
692 | + $first_step = reset(EED_Single_Page_Checkout::$_reg_steps_array); |
|
693 | + return isset($first_step['slug']) ? $first_step['slug'] : 'attendee_information'; |
|
694 | + } |
|
695 | + |
|
696 | + |
|
697 | + /** |
|
698 | + * instantiates each reg step based on the loaded reg_steps array |
|
699 | + * |
|
700 | + * @return bool |
|
701 | + * @throws EE_Error |
|
702 | + * @throws InvalidArgumentException |
|
703 | + * @throws InvalidDataTypeException |
|
704 | + * @throws InvalidInterfaceException |
|
705 | + * @throws ReflectionException |
|
706 | + */ |
|
707 | + private function _load_and_instantiate_reg_steps() |
|
708 | + { |
|
709 | + do_action('AHEE__Single_Page_Checkout___load_and_instantiate_reg_steps__start', $this->checkout); |
|
710 | + // have reg_steps already been instantiated ? |
|
711 | + if ( |
|
712 | + empty($this->checkout->reg_steps) |
|
713 | + || apply_filters('FHEE__Single_Page_Checkout__load_reg_steps__reload_reg_steps', false, $this->checkout) |
|
714 | + ) { |
|
715 | + // if not, then loop through raw reg steps array |
|
716 | + foreach (EED_Single_Page_Checkout::$_reg_steps_array as $order => $reg_step) { |
|
717 | + if (! $this->_load_and_instantiate_reg_step($reg_step, $order)) { |
|
718 | + return false; |
|
719 | + } |
|
720 | + } |
|
721 | + if (isset($this->checkout->reg_steps['registration_confirmation'])) { |
|
722 | + // skip the registration_confirmation page ? |
|
723 | + if (EE_Registry::instance()->CFG->registration->skip_reg_confirmation) { |
|
724 | + // just remove it from the reg steps array |
|
725 | + $this->checkout->remove_reg_step('registration_confirmation', false); |
|
726 | + } elseif ( |
|
727 | + EE_Registry::instance()->CFG->registration->reg_confirmation_last |
|
728 | + ) { |
|
729 | + // set the order to something big like 100 |
|
730 | + $this->checkout->set_reg_step_order('registration_confirmation'); |
|
731 | + } |
|
732 | + } |
|
733 | + // filter the array for good luck |
|
734 | + $this->checkout->reg_steps = apply_filters( |
|
735 | + 'FHEE__Single_Page_Checkout__load_reg_steps__reg_steps', |
|
736 | + $this->checkout->reg_steps |
|
737 | + ); |
|
738 | + // finally re-sort based on the reg step class order properties |
|
739 | + $this->checkout->sort_reg_steps(); |
|
740 | + } else { |
|
741 | + foreach ($this->checkout->reg_steps as $reg_step) { |
|
742 | + // set all current step stati to FALSE |
|
743 | + $reg_step->set_is_current_step(false); |
|
744 | + } |
|
745 | + } |
|
746 | + if (empty($this->checkout->reg_steps)) { |
|
747 | + EE_Error::add_error( |
|
748 | + esc_html__('No Reg Steps were loaded..', 'event_espresso'), |
|
749 | + __FILE__, |
|
750 | + __FUNCTION__, |
|
751 | + __LINE__ |
|
752 | + ); |
|
753 | + return false; |
|
754 | + } |
|
755 | + // make reg step details available to JS |
|
756 | + $this->checkout->set_reg_step_JSON_info(); |
|
757 | + return true; |
|
758 | + } |
|
759 | + |
|
760 | + |
|
761 | + /** |
|
762 | + * _load_and_instantiate_reg_step |
|
763 | + * |
|
764 | + * @param array $reg_step |
|
765 | + * @param int $order |
|
766 | + * @return bool |
|
767 | + * @throws EE_Error |
|
768 | + * @throws ReflectionException |
|
769 | + */ |
|
770 | + private function _load_and_instantiate_reg_step($reg_step = array(), $order = 0) |
|
771 | + { |
|
772 | + // we need a file_path, class_name, and slug to add a reg step |
|
773 | + if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) { |
|
774 | + // if editing a specific step, but this is NOT that step... (and it's not the 'finalize_registration' step) |
|
775 | + if ( |
|
776 | + $this->checkout->reg_url_link |
|
777 | + && $this->checkout->step !== $reg_step['slug'] |
|
778 | + && $reg_step['slug'] !== 'finalize_registration' |
|
779 | + // normally at this point we would NOT load the reg step, but this filter can change that |
|
780 | + && apply_filters( |
|
781 | + 'FHEE__Single_Page_Checkout___load_and_instantiate_reg_step__bypass_reg_step', |
|
782 | + true, |
|
783 | + $reg_step, |
|
784 | + $this->checkout |
|
785 | + ) |
|
786 | + ) { |
|
787 | + return true; |
|
788 | + } |
|
789 | + |
|
790 | + // instantiate step class using file path and class name |
|
791 | + $reg_step_obj = EE_Registry::instance()->load_file( |
|
792 | + $reg_step['file_path'], |
|
793 | + $reg_step['class_name'], |
|
794 | + 'class', |
|
795 | + [$this->checkout], |
|
796 | + false |
|
797 | + ); |
|
798 | + // did we gets the goods ? |
|
799 | + if ($reg_step_obj instanceof EE_SPCO_Reg_Step) { |
|
800 | + // set reg step order based on config |
|
801 | + $reg_step_obj->set_order($order); |
|
802 | + // add instantiated reg step object to the master reg steps array |
|
803 | + $this->checkout->add_reg_step($reg_step_obj); |
|
804 | + } else { |
|
805 | + EE_Error::add_error( |
|
806 | + esc_html__('The current step could not be set.', 'event_espresso'), |
|
807 | + __FILE__, |
|
808 | + __FUNCTION__, |
|
809 | + __LINE__ |
|
810 | + ); |
|
811 | + return false; |
|
812 | + } |
|
813 | + } else { |
|
814 | + if (WP_DEBUG) { |
|
815 | + EE_Error::add_error( |
|
816 | + sprintf( |
|
817 | + esc_html__( |
|
818 | + 'A registration step could not be loaded. One or more of the following data points is invalid:%4$s%5$sFile Path: %1$s%6$s%5$sClass Name: %2$s%6$s%5$sSlug: %3$s%6$s%7$s', |
|
819 | + 'event_espresso' |
|
820 | + ), |
|
821 | + isset($reg_step['file_path']) ? $reg_step['file_path'] : '', |
|
822 | + isset($reg_step['class_name']) ? $reg_step['class_name'] : '', |
|
823 | + isset($reg_step['slug']) ? $reg_step['slug'] : '', |
|
824 | + '<ul>', |
|
825 | + '<li>', |
|
826 | + '</li>', |
|
827 | + '</ul>' |
|
828 | + ), |
|
829 | + __FILE__, |
|
830 | + __FUNCTION__, |
|
831 | + __LINE__ |
|
832 | + ); |
|
833 | + } |
|
834 | + return false; |
|
835 | + } |
|
836 | + return true; |
|
837 | + } |
|
838 | + |
|
839 | + |
|
840 | + /** |
|
841 | + * _verify_transaction_and_get_registrations |
|
842 | + * |
|
843 | + * @return bool |
|
844 | + * @throws EE_Error |
|
845 | + * @throws ReflectionException |
|
846 | + */ |
|
847 | + private function _verify_transaction_and_get_registrations() |
|
848 | + { |
|
849 | + // was there already a valid transaction in the checkout from the session ? |
|
850 | + if (! $this->checkout->transaction instanceof EE_Transaction) { |
|
851 | + // get transaction from db or session |
|
852 | + $this->checkout->transaction = $this->checkout->reg_url_link && ! is_admin() |
|
853 | + ? $this->_get_transaction_and_cart_for_previous_visit() |
|
854 | + : $this->_get_cart_for_current_session_and_setup_new_transaction(); |
|
855 | + if (! $this->checkout->transaction instanceof EE_Transaction) { |
|
856 | + EE_Error::add_error( |
|
857 | + esc_html__( |
|
858 | + 'Your Registration and Transaction information could not be retrieved from the db.', |
|
859 | + 'event_espresso' |
|
860 | + ), |
|
861 | + __FILE__, |
|
862 | + __FUNCTION__, |
|
863 | + __LINE__ |
|
864 | + ); |
|
865 | + $this->checkout->transaction = EE_Transaction::new_instance(); |
|
866 | + // add some style and make it dance |
|
867 | + $this->add_styles_and_scripts($this); |
|
868 | + EED_Single_Page_Checkout::$_initialized = true; |
|
869 | + return false; |
|
870 | + } |
|
871 | + // and the registrations for the transaction |
|
872 | + $this->_get_registrations($this->checkout->transaction); |
|
873 | + } |
|
874 | + return true; |
|
875 | + } |
|
876 | + |
|
877 | + |
|
878 | + /** |
|
879 | + * _get_transaction_and_cart_for_previous_visit |
|
880 | + * |
|
881 | + * @return EE_Transaction|null |
|
882 | + * @throws EE_Error |
|
883 | + * @throws ReflectionException |
|
884 | + */ |
|
885 | + private function _get_transaction_and_cart_for_previous_visit() |
|
886 | + { |
|
887 | + /** @var $TXN_model EEM_Transaction */ |
|
888 | + $TXN_model = EE_Registry::instance()->load_model('Transaction'); |
|
889 | + // because the reg_url_link is present in the request, |
|
890 | + // this is a return visit to SPCO, so we'll get the transaction data from the db |
|
891 | + $transaction = $TXN_model->get_transaction_from_reg_url_link($this->checkout->reg_url_link); |
|
892 | + // verify transaction |
|
893 | + if ($transaction instanceof EE_Transaction) { |
|
894 | + // and get the cart that was used for that transaction |
|
895 | + $this->checkout->cart = $this->_get_cart_for_transaction($transaction); |
|
896 | + return $transaction; |
|
897 | + } |
|
898 | + EE_Error::add_error( |
|
899 | + esc_html__('Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso'), |
|
900 | + __FILE__, |
|
901 | + __FUNCTION__, |
|
902 | + __LINE__ |
|
903 | + ); |
|
904 | + return null; |
|
905 | + } |
|
906 | + |
|
907 | + |
|
908 | + /** |
|
909 | + * _get_cart_for_transaction |
|
910 | + * |
|
911 | + * @param EE_Transaction $transaction |
|
912 | + * @return EE_Cart |
|
913 | + */ |
|
914 | + private function _get_cart_for_transaction($transaction) |
|
915 | + { |
|
916 | + return $this->checkout->get_cart_for_transaction($transaction); |
|
917 | + } |
|
918 | + |
|
919 | + |
|
920 | + /** |
|
921 | + * get_cart_for_transaction |
|
922 | + * |
|
923 | + * @param EE_Transaction $transaction |
|
924 | + * @return EE_Cart |
|
925 | + */ |
|
926 | + public function get_cart_for_transaction(EE_Transaction $transaction) |
|
927 | + { |
|
928 | + return $this->checkout->get_cart_for_transaction($transaction); |
|
929 | + } |
|
930 | + |
|
931 | + |
|
932 | + /** |
|
933 | + * _get_transaction_and_cart_for_current_session |
|
934 | + * generates a new EE_Transaction object and adds it to the $_transaction property. |
|
935 | + * |
|
936 | + * @return EE_Transaction |
|
937 | + * @throws EE_Error |
|
938 | + * @throws ReflectionException |
|
939 | + */ |
|
940 | + private function _get_cart_for_current_session_and_setup_new_transaction() |
|
941 | + { |
|
942 | + // if there's no transaction, then this is the FIRST visit to SPCO |
|
943 | + // so load up the cart ( passing nothing for the TXN because it doesn't exist yet ) |
|
944 | + $this->checkout->cart = $this->_get_cart_for_transaction(null); |
|
945 | + // and then create a new transaction |
|
946 | + $transaction = $this->_initialize_transaction(); |
|
947 | + // verify transaction |
|
948 | + if ($transaction instanceof EE_Transaction) { |
|
949 | + // save it so that we have an ID for other objects to use |
|
950 | + $transaction->save(); |
|
951 | + // and save TXN data to the cart |
|
952 | + $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn($transaction->ID()); |
|
953 | + } else { |
|
954 | + EE_Error::add_error( |
|
955 | + esc_html__('A Valid Transaction could not be initialized.', 'event_espresso'), |
|
956 | + __FILE__, |
|
957 | + __FUNCTION__, |
|
958 | + __LINE__ |
|
959 | + ); |
|
960 | + } |
|
961 | + return $transaction; |
|
962 | + } |
|
963 | + |
|
964 | + |
|
965 | + /** |
|
966 | + * generates a new EE_Transaction object and adds it to the $_transaction property. |
|
967 | + * |
|
968 | + * @return EE_Transaction|null |
|
969 | + */ |
|
970 | + private function _initialize_transaction() |
|
971 | + { |
|
972 | + try { |
|
973 | + // ensure cart totals have been calculated |
|
974 | + $this->checkout->cart->get_grand_total()->recalculate_total_including_taxes(); |
|
975 | + // grab the cart grand total |
|
976 | + $cart_total = $this->checkout->cart->get_cart_grand_total(); |
|
977 | + // create new TXN |
|
978 | + $transaction = EE_Transaction::new_instance( |
|
979 | + array( |
|
980 | + 'TXN_reg_steps' => $this->checkout->initialize_txn_reg_steps_array(), |
|
981 | + 'TXN_total' => $cart_total > 0 ? $cart_total : 0, |
|
982 | + 'TXN_paid' => 0, |
|
983 | + 'STS_ID' => EEM_Transaction::failed_status_code, |
|
984 | + ) |
|
985 | + ); |
|
986 | + // save it so that we have an ID for other objects to use |
|
987 | + $transaction->save(); |
|
988 | + // set cron job for following up on TXNs after their session has expired |
|
989 | + EE_Cron_Tasks::schedule_expired_transaction_check( |
|
990 | + EE_Registry::instance()->SSN->expiration() + 1, |
|
991 | + $transaction->ID() |
|
992 | + ); |
|
993 | + return $transaction; |
|
994 | + } catch (Exception $e) { |
|
995 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
996 | + } |
|
997 | + return null; |
|
998 | + } |
|
999 | + |
|
1000 | + |
|
1001 | + /** |
|
1002 | + * _get_registrations |
|
1003 | + * |
|
1004 | + * @param EE_Transaction $transaction |
|
1005 | + * @return void |
|
1006 | + * @throws EE_Error |
|
1007 | + * @throws ReflectionException |
|
1008 | + */ |
|
1009 | + private function _get_registrations(EE_Transaction $transaction) |
|
1010 | + { |
|
1011 | + // first step: grab the registrants { : o |
|
1012 | + $registrations = $transaction->registrations($this->checkout->reg_cache_where_params); |
|
1013 | + $this->checkout->total_ticket_count = count($registrations); |
|
1014 | + // verify registrations have been set |
|
1015 | + if (empty($registrations)) { |
|
1016 | + // if no cached registrations, then check the db |
|
1017 | + $registrations = $transaction->registrations($this->checkout->reg_cache_where_params); |
|
1018 | + // still nothing ? well as long as this isn't a revisit |
|
1019 | + if (empty($registrations) && ! $this->checkout->revisit) { |
|
1020 | + // generate new registrations from scratch |
|
1021 | + $registrations = $this->_initialize_registrations($transaction); |
|
1022 | + } |
|
1023 | + } |
|
1024 | + // sort by their original registration order |
|
1025 | + usort($registrations, array('EED_Single_Page_Checkout', 'sort_registrations_by_REG_count')); |
|
1026 | + // then loop thru the array |
|
1027 | + foreach ($registrations as $registration) { |
|
1028 | + // verify each registration |
|
1029 | + if ($registration instanceof EE_Registration) { |
|
1030 | + // we display all attendee info for the primary registrant |
|
1031 | + if ( |
|
1032 | + $this->checkout->reg_url_link === $registration->reg_url_link() |
|
1033 | + && $registration->is_primary_registrant() |
|
1034 | + ) { |
|
1035 | + $this->checkout->primary_revisit = true; |
|
1036 | + break; |
|
1037 | + } |
|
1038 | + if ($this->checkout->revisit && $this->checkout->reg_url_link !== $registration->reg_url_link()) { |
|
1039 | + // but hide info if it doesn't belong to you |
|
1040 | + $transaction->clear_cache('Registration', $registration->ID()); |
|
1041 | + $this->checkout->total_ticket_count--; |
|
1042 | + } |
|
1043 | + $this->checkout->set_reg_status_updated($registration->ID(), false); |
|
1044 | + } |
|
1045 | + } |
|
1046 | + } |
|
1047 | + |
|
1048 | + |
|
1049 | + /** |
|
1050 | + * adds related EE_Registration objects for each ticket in the cart to the current EE_Transaction object |
|
1051 | + * |
|
1052 | + * @param EE_Transaction $transaction |
|
1053 | + * @return array |
|
1054 | + * @throws EE_Error |
|
1055 | + * @throws ReflectionException |
|
1056 | + */ |
|
1057 | + private function _initialize_registrations(EE_Transaction $transaction) |
|
1058 | + { |
|
1059 | + $att_nmbr = 0; |
|
1060 | + $registrations = array(); |
|
1061 | + if ($transaction instanceof EE_Transaction) { |
|
1062 | + /** @type EE_Registration_Processor $registration_processor */ |
|
1063 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
1064 | + $this->checkout->total_ticket_count = $this->checkout->cart->all_ticket_quantity_count(); |
|
1065 | + // now let's add the cart items to the $transaction |
|
1066 | + foreach ($this->checkout->cart->get_tickets() as $line_item) { |
|
1067 | + // do the following for each ticket of this type they selected |
|
1068 | + for ($x = 1; $x <= $line_item->quantity(); $x++) { |
|
1069 | + $att_nmbr++; |
|
1070 | + /** @var CreateRegistrationCommand $CreateRegistrationCommand */ |
|
1071 | + $CreateRegistrationCommand = EE_Registry::instance()->create( |
|
1072 | + CreateRegistrationCommand::class, |
|
1073 | + [ |
|
1074 | + $transaction, |
|
1075 | + $line_item, |
|
1076 | + $att_nmbr, |
|
1077 | + $this->checkout->total_ticket_count, |
|
1078 | + ] |
|
1079 | + ); |
|
1080 | + // override capabilities for frontend registrations |
|
1081 | + if ($this->request->isFrontend()) { |
|
1082 | + $CreateRegistrationCommand->setCapCheck( |
|
1083 | + new PublicCapabilities('', 'create_new_registration') |
|
1084 | + ); |
|
1085 | + } |
|
1086 | + $registration = EE_Registry::instance()->BUS->execute($CreateRegistrationCommand); |
|
1087 | + if (! $registration instanceof EE_Registration) { |
|
1088 | + throw new InvalidEntityException($registration, 'EE_Registration'); |
|
1089 | + } |
|
1090 | + $registrations[ $registration->ID() ] = $registration; |
|
1091 | + } |
|
1092 | + } |
|
1093 | + $registration_processor->fix_reg_final_price_rounding_issue($transaction); |
|
1094 | + } |
|
1095 | + return $registrations; |
|
1096 | + } |
|
1097 | + |
|
1098 | + |
|
1099 | + /** |
|
1100 | + * sorts registrations by REG_count |
|
1101 | + * |
|
1102 | + * @param EE_Registration $reg_A |
|
1103 | + * @param EE_Registration $reg_B |
|
1104 | + * @return int |
|
1105 | + */ |
|
1106 | + public static function sort_registrations_by_REG_count(EE_Registration $reg_A, EE_Registration $reg_B) |
|
1107 | + { |
|
1108 | + // this shouldn't ever happen within the same TXN, but oh well |
|
1109 | + if ($reg_A->count() === $reg_B->count()) { |
|
1110 | + return 0; |
|
1111 | + } |
|
1112 | + return ($reg_A->count() > $reg_B->count()) ? 1 : -1; |
|
1113 | + } |
|
1114 | + |
|
1115 | + |
|
1116 | + /** |
|
1117 | + * _final_verifications |
|
1118 | + * just makes sure that everything is set up correctly before proceeding |
|
1119 | + * |
|
1120 | + * @return bool |
|
1121 | + * @throws EE_Error |
|
1122 | + * @throws ReflectionException |
|
1123 | + */ |
|
1124 | + private function _final_verifications() |
|
1125 | + { |
|
1126 | + // filter checkout |
|
1127 | + $this->checkout = apply_filters( |
|
1128 | + 'FHEE__EED_Single_Page_Checkout___final_verifications__checkout', |
|
1129 | + $this->checkout |
|
1130 | + ); |
|
1131 | + // verify that current step is still set correctly |
|
1132 | + if (! $this->checkout->current_step instanceof EE_SPCO_Reg_Step) { |
|
1133 | + EE_Error::add_error( |
|
1134 | + esc_html__( |
|
1135 | + 'We\'re sorry but the registration process can not proceed because one or more registration steps were not setup correctly. Please refresh the page and try again or contact support.', |
|
1136 | + 'event_espresso' |
|
1137 | + ), |
|
1138 | + __FILE__, |
|
1139 | + __FUNCTION__, |
|
1140 | + __LINE__ |
|
1141 | + ); |
|
1142 | + return false; |
|
1143 | + } |
|
1144 | + // if returning to SPCO, then verify that primary registrant is set |
|
1145 | + if (! empty($this->checkout->reg_url_link)) { |
|
1146 | + $valid_registrant = $this->checkout->transaction->primary_registration(); |
|
1147 | + if (! $valid_registrant instanceof EE_Registration) { |
|
1148 | + EE_Error::add_error( |
|
1149 | + esc_html__( |
|
1150 | + 'We\'re sorry but there appears to be an error with the "reg_url_link" or the primary registrant for this transaction. Please refresh the page and try again or contact support.', |
|
1151 | + 'event_espresso' |
|
1152 | + ), |
|
1153 | + __FILE__, |
|
1154 | + __FUNCTION__, |
|
1155 | + __LINE__ |
|
1156 | + ); |
|
1157 | + return false; |
|
1158 | + } |
|
1159 | + $valid_registrant = null; |
|
1160 | + foreach ($this->checkout->transaction->registrations($this->checkout->reg_cache_where_params) as $registration) { |
|
1161 | + if ( |
|
1162 | + $registration instanceof EE_Registration |
|
1163 | + && $registration->reg_url_link() === $this->checkout->reg_url_link |
|
1164 | + ) { |
|
1165 | + $valid_registrant = $registration; |
|
1166 | + } |
|
1167 | + } |
|
1168 | + if (! $valid_registrant instanceof EE_Registration) { |
|
1169 | + // hmmm... maybe we have the wrong session because the user is opening multiple tabs ? |
|
1170 | + if (EED_Single_Page_Checkout::$_checkout_verified) { |
|
1171 | + // clear the session, mark the checkout as unverified, and try again |
|
1172 | + EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
1173 | + EED_Single_Page_Checkout::$_initialized = false; |
|
1174 | + EED_Single_Page_Checkout::$_checkout_verified = false; |
|
1175 | + $this->_initialize(); |
|
1176 | + EE_Error::reset_notices(); |
|
1177 | + return false; |
|
1178 | + } |
|
1179 | + EE_Error::add_error( |
|
1180 | + esc_html__( |
|
1181 | + 'We\'re sorry but there appears to be an error with the "reg_url_link" or the transaction itself. Please refresh the page and try again or contact support.', |
|
1182 | + 'event_espresso' |
|
1183 | + ), |
|
1184 | + __FILE__, |
|
1185 | + __FUNCTION__, |
|
1186 | + __LINE__ |
|
1187 | + ); |
|
1188 | + return false; |
|
1189 | + } |
|
1190 | + } |
|
1191 | + // now that things have been kinda sufficiently verified, |
|
1192 | + // let's add the checkout to the session so that it's available to other systems |
|
1193 | + EE_Registry::instance()->SSN->set_checkout($this->checkout); |
|
1194 | + return true; |
|
1195 | + } |
|
1196 | + |
|
1197 | + |
|
1198 | + /** |
|
1199 | + * _initialize_reg_steps |
|
1200 | + * first makes sure that EE_Transaction_Processor::set_reg_step_initiated() is called as required |
|
1201 | + * then loops thru all of the active reg steps and calls the initialize_reg_step() method |
|
1202 | + * |
|
1203 | + * @param bool $reinitializing |
|
1204 | + * @throws EE_Error |
|
1205 | + */ |
|
1206 | + private function _initialize_reg_steps($reinitializing = false) |
|
1207 | + { |
|
1208 | + $this->checkout->set_reg_step_initiated($this->checkout->current_step); |
|
1209 | + // loop thru all steps to call their individual "initialize" methods and set i18n strings for JS |
|
1210 | + foreach ($this->checkout->reg_steps as $reg_step) { |
|
1211 | + if (! $reg_step->initialize_reg_step()) { |
|
1212 | + // if not initialized then maybe this step is being removed... |
|
1213 | + if (! $reinitializing && $reg_step->is_current_step()) { |
|
1214 | + // if it was the current step, then we need to start over here |
|
1215 | + $this->_initialize_reg_steps(true); |
|
1216 | + return; |
|
1217 | + } |
|
1218 | + continue; |
|
1219 | + } |
|
1220 | + // add css and JS for current step |
|
1221 | + $this->add_styles_and_scripts($reg_step); |
|
1222 | + if ($reg_step->is_current_step()) { |
|
1223 | + // the text that appears on the reg step form submit button |
|
1224 | + $reg_step->set_submit_button_text(); |
|
1225 | + } |
|
1226 | + } |
|
1227 | + // dynamically creates hook point like: AHEE__Single_Page_Checkout___initialize_reg_step__attendee_information |
|
1228 | + do_action( |
|
1229 | + "AHEE__Single_Page_Checkout___initialize_reg_step__{$this->checkout->current_step->slug()}", |
|
1230 | + $this->checkout->current_step |
|
1231 | + ); |
|
1232 | + } |
|
1233 | + |
|
1234 | + |
|
1235 | + /** |
|
1236 | + * _check_form_submission |
|
1237 | + * |
|
1238 | + * @return boolean |
|
1239 | + * @throws EE_Error |
|
1240 | + * @throws ReflectionException |
|
1241 | + */ |
|
1242 | + private function _check_form_submission() |
|
1243 | + { |
|
1244 | + // does this request require the reg form to be generated ? |
|
1245 | + if ($this->checkout->generate_reg_form) { |
|
1246 | + // ever heard that song by Blue Rodeo ? |
|
1247 | + try { |
|
1248 | + $this->checkout->current_step->reg_form = $this->checkout->current_step->generate_reg_form(); |
|
1249 | + // if not displaying a form, then check for form submission |
|
1250 | + if ( |
|
1251 | + $this->checkout->process_form_submission |
|
1252 | + && $this->checkout->current_step->reg_form->was_submitted() |
|
1253 | + ) { |
|
1254 | + // clear out any old data in case this step is being run again |
|
1255 | + $this->checkout->current_step->set_valid_data(array()); |
|
1256 | + // capture submitted form data |
|
1257 | + $request_data = $this->request->requestParams(); |
|
1258 | + $this->checkout->current_step->reg_form->receive_form_submission( |
|
1259 | + (array) apply_filters( |
|
1260 | + 'FHEE__Single_Page_Checkout___check_form_submission__request_params', |
|
1261 | + $request_data, |
|
1262 | + $this->checkout |
|
1263 | + ) |
|
1264 | + ); |
|
1265 | + // validate submitted form data |
|
1266 | + if (! $this->checkout->continue_reg || ! $this->checkout->current_step->reg_form->is_valid()) { |
|
1267 | + // thou shall not pass !!! |
|
1268 | + $this->checkout->continue_reg = false; |
|
1269 | + // any form validation errors? |
|
1270 | + if ($this->checkout->current_step->reg_form->submission_error_message() !== '') { |
|
1271 | + EE_Error::add_error( |
|
1272 | + $this->checkout->current_step->reg_form->submission_error_message(), |
|
1273 | + __FILE__, |
|
1274 | + __FUNCTION__, |
|
1275 | + __LINE__ |
|
1276 | + ); |
|
1277 | + } |
|
1278 | + // well not really... what will happen is |
|
1279 | + // we'll just get redirected back to redo the current step |
|
1280 | + $this->go_to_next_step(); |
|
1281 | + return false; |
|
1282 | + } |
|
1283 | + } |
|
1284 | + } catch (EE_Error $e) { |
|
1285 | + $e->get_error(); |
|
1286 | + } |
|
1287 | + } |
|
1288 | + return true; |
|
1289 | + } |
|
1290 | + |
|
1291 | + |
|
1292 | + /** |
|
1293 | + * _process_action |
|
1294 | + * |
|
1295 | + * @return void |
|
1296 | + * @throws EE_Error |
|
1297 | + * @throws ReflectionException |
|
1298 | + */ |
|
1299 | + private function _process_form_action() |
|
1300 | + { |
|
1301 | + // what cha wanna do? |
|
1302 | + switch ($this->checkout->action) { |
|
1303 | + // AJAX next step reg form |
|
1304 | + case 'display_spco_reg_step': |
|
1305 | + $this->checkout->redirect = false; |
|
1306 | + if ($this->request->isAjax()) { |
|
1307 | + $this->checkout->json_response->set_reg_step_html( |
|
1308 | + $this->checkout->current_step->display_reg_form() |
|
1309 | + ); |
|
1310 | + } |
|
1311 | + break; |
|
1312 | + default: |
|
1313 | + // meh... do one of those other steps first |
|
1314 | + if ( |
|
1315 | + ! empty($this->checkout->action) |
|
1316 | + && is_callable(array($this->checkout->current_step, $this->checkout->action)) |
|
1317 | + ) { |
|
1318 | + // dynamically creates hook point like: |
|
1319 | + // AHEE__Single_Page_Checkout__before_attendee_information__process_reg_step |
|
1320 | + do_action( |
|
1321 | + "AHEE__Single_Page_Checkout__before_{$this->checkout->current_step->slug()}__{$this->checkout->action}", |
|
1322 | + $this->checkout->current_step |
|
1323 | + ); |
|
1324 | + $process_reg_step = apply_filters( |
|
1325 | + "AHEE__Single_Page_Checkout__process_reg_step__{$this->checkout->current_step->slug()}__{$this->checkout->action}", |
|
1326 | + true, |
|
1327 | + $this->checkout->current_step, |
|
1328 | + $this |
|
1329 | + ); |
|
1330 | + // call action on current step |
|
1331 | + if ($process_reg_step && call_user_func([$this->checkout->current_step, $this->checkout->action])) { |
|
1332 | + // good registrant, you get to proceed |
|
1333 | + if ( |
|
1334 | + $this->checkout->current_step->success_message() !== '' |
|
1335 | + && apply_filters( |
|
1336 | + 'FHEE__Single_Page_Checkout___process_form_action__display_success', |
|
1337 | + false |
|
1338 | + ) |
|
1339 | + ) { |
|
1340 | + EE_Error::add_success( |
|
1341 | + $this->checkout->current_step->success_message() |
|
1342 | + . '<br />' . $this->checkout->next_step->_instructions() |
|
1343 | + ); |
|
1344 | + } |
|
1345 | + // pack it up, pack it in... |
|
1346 | + $this->_setup_redirect(); |
|
1347 | + } |
|
1348 | + // dynamically creates hook point like: |
|
1349 | + // AHEE__Single_Page_Checkout__after_payment_options__process_reg_step |
|
1350 | + do_action( |
|
1351 | + "AHEE__Single_Page_Checkout__after_{$this->checkout->current_step->slug()}__{$this->checkout->action}", |
|
1352 | + $this->checkout->current_step |
|
1353 | + ); |
|
1354 | + } else { |
|
1355 | + EE_Error::add_error( |
|
1356 | + sprintf( |
|
1357 | + esc_html__( |
|
1358 | + 'The requested form action "%s" does not exist for the current "%s" registration step.', |
|
1359 | + 'event_espresso' |
|
1360 | + ), |
|
1361 | + $this->checkout->action, |
|
1362 | + $this->checkout->current_step->name() |
|
1363 | + ), |
|
1364 | + __FILE__, |
|
1365 | + __FUNCTION__, |
|
1366 | + __LINE__ |
|
1367 | + ); |
|
1368 | + } |
|
1369 | + // end default |
|
1370 | + } |
|
1371 | + // store our progress so far |
|
1372 | + $this->checkout->stash_transaction_and_checkout(); |
|
1373 | + // advance to the next step! If you pass GO, collect $200 |
|
1374 | + $this->go_to_next_step(); |
|
1375 | + } |
|
1376 | + |
|
1377 | + |
|
1378 | + /** |
|
1379 | + * @param EED_Single_Page_Checkout|EE_SPCO_Reg_Step $target an object with the method `translate_js_strings` and |
|
1380 | + * `enqueue_styles_and_scripts`. |
|
1381 | + * @return void |
|
1382 | + */ |
|
1383 | + public function add_styles_and_scripts($target) |
|
1384 | + { |
|
1385 | + // i18n |
|
1386 | + $target->translate_js_strings(); |
|
1387 | + if ($this->checkout->admin_request) { |
|
1388 | + add_action('admin_enqueue_scripts', array($target, 'enqueue_styles_and_scripts'), 10); |
|
1389 | + } else { |
|
1390 | + add_action('wp_enqueue_scripts', array($target, 'enqueue_styles_and_scripts'), 10); |
|
1391 | + } |
|
1392 | + } |
|
1393 | + |
|
1394 | + /** |
|
1395 | + * translate_js_strings |
|
1396 | + * |
|
1397 | + * @return void |
|
1398 | + */ |
|
1399 | + public function translate_js_strings() |
|
1400 | + { |
|
1401 | + EE_Registry::$i18n_js_strings['revisit'] = $this->checkout->revisit; |
|
1402 | + EE_Registry::$i18n_js_strings['e_reg_url_link'] = $this->checkout->reg_url_link; |
|
1403 | + EE_Registry::$i18n_js_strings['server_error'] = esc_html__( |
|
1404 | + 'An unknown error occurred on the server while attempting to process your request. Please refresh the page and try again or contact support.', |
|
1405 | + 'event_espresso' |
|
1406 | + ); |
|
1407 | + EE_Registry::$i18n_js_strings['invalid_json_response'] = esc_html__( |
|
1408 | + 'An invalid response was returned from the server while attempting to process your request. Please refresh the page and try again or contact support.', |
|
1409 | + 'event_espresso' |
|
1410 | + ); |
|
1411 | + EE_Registry::$i18n_js_strings['validation_error'] = esc_html__( |
|
1412 | + 'There appears to be a problem with the form validation configuration! Please check the admin settings or contact support.', |
|
1413 | + 'event_espresso' |
|
1414 | + ); |
|
1415 | + EE_Registry::$i18n_js_strings['invalid_payment_method'] = esc_html__( |
|
1416 | + 'There appears to be a problem with the payment method configuration! Please refresh the page and try again or contact support.', |
|
1417 | + 'event_espresso' |
|
1418 | + ); |
|
1419 | + EE_Registry::$i18n_js_strings['reg_step_error'] = esc_html__( |
|
1420 | + 'This registration step could not be completed. Please refresh the page and try again.', |
|
1421 | + 'event_espresso' |
|
1422 | + ); |
|
1423 | + EE_Registry::$i18n_js_strings['invalid_coupon'] = esc_html__( |
|
1424 | + 'We\'re sorry but that coupon code does not appear to be valid. If this is incorrect, please contact the site administrator.', |
|
1425 | + 'event_espresso' |
|
1426 | + ); |
|
1427 | + EE_Registry::$i18n_js_strings['process_registration'] = sprintf( |
|
1428 | + esc_html__( |
|
1429 | + 'Please wait while we process your registration.%sDo not refresh the page or navigate away while this is happening.%sThank you for your patience.', |
|
1430 | + 'event_espresso' |
|
1431 | + ), |
|
1432 | + '<br/>', |
|
1433 | + '<br/>' |
|
1434 | + ); |
|
1435 | + EE_Registry::$i18n_js_strings['language'] = get_bloginfo('language'); |
|
1436 | + EE_Registry::$i18n_js_strings['EESID'] = EE_Registry::instance()->SSN->id(); |
|
1437 | + EE_Registry::$i18n_js_strings['currency'] = EE_Registry::instance()->CFG->currency; |
|
1438 | + EE_Registry::$i18n_js_strings['datepicker_yearRange'] = '-150:+20'; |
|
1439 | + EE_Registry::$i18n_js_strings['timer_years'] = esc_html__('years', 'event_espresso'); |
|
1440 | + EE_Registry::$i18n_js_strings['timer_months'] = esc_html__('months', 'event_espresso'); |
|
1441 | + EE_Registry::$i18n_js_strings['timer_weeks'] = esc_html__('weeks', 'event_espresso'); |
|
1442 | + EE_Registry::$i18n_js_strings['timer_days'] = esc_html__('days', 'event_espresso'); |
|
1443 | + EE_Registry::$i18n_js_strings['timer_hours'] = esc_html__('hours', 'event_espresso'); |
|
1444 | + EE_Registry::$i18n_js_strings['timer_minutes'] = esc_html__('minutes', 'event_espresso'); |
|
1445 | + EE_Registry::$i18n_js_strings['timer_seconds'] = esc_html__('seconds', 'event_espresso'); |
|
1446 | + EE_Registry::$i18n_js_strings['timer_year'] = esc_html__('year', 'event_espresso'); |
|
1447 | + EE_Registry::$i18n_js_strings['timer_month'] = esc_html__('month', 'event_espresso'); |
|
1448 | + EE_Registry::$i18n_js_strings['timer_week'] = esc_html__('week', 'event_espresso'); |
|
1449 | + EE_Registry::$i18n_js_strings['timer_day'] = esc_html__('day', 'event_espresso'); |
|
1450 | + EE_Registry::$i18n_js_strings['timer_hour'] = esc_html__('hour', 'event_espresso'); |
|
1451 | + EE_Registry::$i18n_js_strings['timer_minute'] = esc_html__('minute', 'event_espresso'); |
|
1452 | + EE_Registry::$i18n_js_strings['timer_second'] = esc_html__('second', 'event_espresso'); |
|
1453 | + EE_Registry::$i18n_js_strings['registration_expiration_notice'] = EED_Single_Page_Checkout::getRegistrationExpirationNotice( |
|
1454 | + ); |
|
1455 | + EE_Registry::$i18n_js_strings['ajax_submit'] = apply_filters( |
|
1456 | + 'FHEE__Single_Page_Checkout__translate_js_strings__ajax_submit', |
|
1457 | + true |
|
1458 | + ); |
|
1459 | + EE_Registry::$i18n_js_strings['session_extension'] = absint( |
|
1460 | + apply_filters('FHEE__EE_Session__extend_expiration__seconds_added', 10 * MINUTE_IN_SECONDS) |
|
1461 | + ); |
|
1462 | + EE_Registry::$i18n_js_strings['session_expiration'] = gmdate( |
|
1463 | + 'M d, Y H:i:s', |
|
1464 | + EE_Registry::instance()->SSN->expiration() + (get_option('gmt_offset') * HOUR_IN_SECONDS) |
|
1465 | + ); |
|
1466 | + } |
|
1467 | + |
|
1468 | + |
|
1469 | + /** |
|
1470 | + * enqueue_styles_and_scripts |
|
1471 | + * |
|
1472 | + * @return void |
|
1473 | + * @throws EE_Error |
|
1474 | + */ |
|
1475 | + public function enqueue_styles_and_scripts() |
|
1476 | + { |
|
1477 | + // load css |
|
1478 | + wp_register_style( |
|
1479 | + 'single_page_checkout', |
|
1480 | + SPCO_CSS_URL . 'single_page_checkout.css', |
|
1481 | + array('espresso_default'), |
|
1482 | + EVENT_ESPRESSO_VERSION |
|
1483 | + ); |
|
1484 | + wp_enqueue_style('single_page_checkout'); |
|
1485 | + // load JS |
|
1486 | + wp_register_script( |
|
1487 | + 'jquery_plugin', |
|
1488 | + EE_GLOBAL_ASSETS_URL . 'scripts/jquery.plugin.min.js', |
|
1489 | + array('jquery'), |
|
1490 | + '1.0.1', |
|
1491 | + true |
|
1492 | + ); |
|
1493 | + wp_register_script( |
|
1494 | + 'jquery_countdown', |
|
1495 | + EE_GLOBAL_ASSETS_URL . 'scripts/jquery.countdown.min.js', |
|
1496 | + array('jquery_plugin'), |
|
1497 | + '2.1.0', |
|
1498 | + true |
|
1499 | + ); |
|
1500 | + wp_register_script( |
|
1501 | + 'single_page_checkout', |
|
1502 | + SPCO_JS_URL . 'single_page_checkout.js', |
|
1503 | + array('espresso_core', 'underscore', 'ee_form_section_validation'), |
|
1504 | + EVENT_ESPRESSO_VERSION, |
|
1505 | + true |
|
1506 | + ); |
|
1507 | + if ($this->checkout->registration_form instanceof EE_Form_Section_Proper) { |
|
1508 | + $this->checkout->registration_form->enqueue_js(); |
|
1509 | + } |
|
1510 | + if ($this->checkout->current_step->reg_form instanceof EE_Form_Section_Proper) { |
|
1511 | + $this->checkout->current_step->reg_form->enqueue_js(); |
|
1512 | + } |
|
1513 | + wp_enqueue_script('single_page_checkout'); |
|
1514 | + if (apply_filters('FHEE__registration_page_wrapper_template__display_time_limit', false)) { |
|
1515 | + wp_enqueue_script('jquery_countdown'); |
|
1516 | + } |
|
1517 | + /** |
|
1518 | + * global action hook for enqueueing styles and scripts with |
|
1519 | + * spco calls. |
|
1520 | + */ |
|
1521 | + do_action('AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts', $this); |
|
1522 | + /** |
|
1523 | + * dynamic action hook for enqueueing styles and scripts with spco calls. |
|
1524 | + * The hook will end up being something like: |
|
1525 | + * AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__attendee_information |
|
1526 | + */ |
|
1527 | + do_action( |
|
1528 | + 'AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__' . $this->checkout->current_step->slug(), |
|
1529 | + $this |
|
1530 | + ); |
|
1531 | + } |
|
1532 | + |
|
1533 | + |
|
1534 | + /** |
|
1535 | + * display the Registration Single Page Checkout Form |
|
1536 | + * |
|
1537 | + * @return void |
|
1538 | + * @throws EE_Error |
|
1539 | + * @throws ReflectionException |
|
1540 | + */ |
|
1541 | + private function _display_spco_reg_form() |
|
1542 | + { |
|
1543 | + // if registering via the admin, just display the reg form for the current step |
|
1544 | + if ($this->checkout->admin_request) { |
|
1545 | + EED_Single_Page_Checkout::getResponse()->addOutput($this->checkout->current_step->display_reg_form()); |
|
1546 | + } else { |
|
1547 | + // add powered by EE msg |
|
1548 | + add_action('AHEE__SPCO__reg_form_footer', array('EED_Single_Page_Checkout', 'display_registration_footer')); |
|
1549 | + $empty_cart = count( |
|
1550 | + $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params) |
|
1551 | + ) < 1; |
|
1552 | + EE_Registry::$i18n_js_strings['empty_cart'] = $empty_cart; |
|
1553 | + $cookies_not_set_msg = ''; |
|
1554 | + if ($empty_cart) { |
|
1555 | + $cookies_not_set_msg = apply_filters( |
|
1556 | + 'FHEE__Single_Page_Checkout__display_spco_reg_form__cookies_not_set_msg', |
|
1557 | + sprintf( |
|
1558 | + esc_html__( |
|
1559 | + '%1$s%3$sIt appears your browser is not currently set to accept Cookies%4$s%5$sIn order to register for events, you need to enable cookies.%7$sIf you require assistance, then click the following link to learn how to %8$senable cookies%9$s%6$s%2$s', |
|
1560 | + 'event_espresso' |
|
1561 | + ), |
|
1562 | + '<div class="ee-attention hidden" id="ee-cookies-not-set-msg">', |
|
1563 | + '</div>', |
|
1564 | + '<h6 class="important-notice">', |
|
1565 | + '</h6>', |
|
1566 | + '<p>', |
|
1567 | + '</p>', |
|
1568 | + '<br />', |
|
1569 | + '<a href="https://www.whatismybrowser.com/guides/how-to-enable-cookies/" target="_blank" rel="noopener noreferrer">', |
|
1570 | + '</a>' |
|
1571 | + ) |
|
1572 | + ); |
|
1573 | + } |
|
1574 | + $this->checkout->registration_form = new EE_Form_Section_Proper( |
|
1575 | + array( |
|
1576 | + 'name' => 'single-page-checkout', |
|
1577 | + 'html_id' => 'ee-single-page-checkout-dv', |
|
1578 | + 'layout_strategy' => |
|
1579 | + new EE_Template_Layout( |
|
1580 | + array( |
|
1581 | + 'layout_template_file' => SPCO_TEMPLATES_PATH . 'registration_page_wrapper.template.php', |
|
1582 | + 'template_args' => array( |
|
1583 | + 'empty_cart' => $empty_cart, |
|
1584 | + 'revisit' => $this->checkout->revisit, |
|
1585 | + 'reg_steps' => $this->checkout->reg_steps, |
|
1586 | + 'next_step' => $this->checkout->next_step instanceof EE_SPCO_Reg_Step |
|
1587 | + ? $this->checkout->next_step->slug() |
|
1588 | + : '', |
|
1589 | + 'empty_msg' => apply_filters( |
|
1590 | + 'FHEE__Single_Page_Checkout__display_spco_reg_form__empty_msg', |
|
1591 | + sprintf( |
|
1592 | + esc_html__( |
|
1593 | + 'You need to %1$sReturn to Events list%2$sselect at least one event%3$s before you can proceed with the registration process.', |
|
1594 | + 'event_espresso' |
|
1595 | + ), |
|
1596 | + '<a href="' |
|
1597 | + . get_post_type_archive_link('espresso_events') |
|
1598 | + . '" title="', |
|
1599 | + '">', |
|
1600 | + '</a>' |
|
1601 | + ) |
|
1602 | + ), |
|
1603 | + 'cookies_not_set_msg' => $cookies_not_set_msg, |
|
1604 | + 'registration_time_limit' => $this->checkout->get_registration_time_limit(), |
|
1605 | + 'session_expiration' => gmdate( |
|
1606 | + 'M d, Y H:i:s', |
|
1607 | + EE_Registry::instance()->SSN->expiration() |
|
1608 | + + (get_option('gmt_offset') * HOUR_IN_SECONDS) |
|
1609 | + ), |
|
1610 | + ), |
|
1611 | + ) |
|
1612 | + ), |
|
1613 | + ) |
|
1614 | + ); |
|
1615 | + // load template and add to output sent that gets filtered into the_content() |
|
1616 | + EED_Single_Page_Checkout::getResponse()->addOutput($this->checkout->registration_form->get_html()); |
|
1617 | + } |
|
1618 | + } |
|
1619 | + |
|
1620 | + |
|
1621 | + /** |
|
1622 | + * add_extra_finalize_registration_inputs |
|
1623 | + * |
|
1624 | + * @param $next_step |
|
1625 | + * @internal param string $label |
|
1626 | + * @return void |
|
1627 | + */ |
|
1628 | + public function add_extra_finalize_registration_inputs($next_step) |
|
1629 | + { |
|
1630 | + if ($next_step === 'finalize_registration') { |
|
1631 | + echo '<div id="spco-extra-finalize_registration-inputs-dv"></div>'; |
|
1632 | + } |
|
1633 | + } |
|
1634 | + |
|
1635 | + |
|
1636 | + /** |
|
1637 | + * display_registration_footer |
|
1638 | + * |
|
1639 | + * @return string |
|
1640 | + */ |
|
1641 | + public static function display_registration_footer() |
|
1642 | + { |
|
1643 | + if ( |
|
1644 | + apply_filters( |
|
1645 | + 'FHEE__EE_Front__Controller__show_reg_footer', |
|
1646 | + EE_Registry::instance()->CFG->admin->show_reg_footer |
|
1647 | + ) |
|
1648 | + ) { |
|
1649 | + add_filter( |
|
1650 | + 'FHEE__EEH_Template__powered_by_event_espresso__url', |
|
1651 | + function ($url) { |
|
1652 | + return apply_filters('FHEE__EE_Front_Controller__registration_footer__url', $url); |
|
1653 | + } |
|
1654 | + ); |
|
1655 | + echo apply_filters( |
|
1656 | + 'FHEE__EE_Front_Controller__display_registration_footer', |
|
1657 | + EEH_Template::powered_by_event_espresso( |
|
1658 | + '', |
|
1659 | + 'espresso-registration-footer-dv', |
|
1660 | + array('utm_content' => 'registration_checkout') |
|
1661 | + ) |
|
1662 | + ); |
|
1663 | + } |
|
1664 | + return ''; |
|
1665 | + } |
|
1666 | + |
|
1667 | + |
|
1668 | + /** |
|
1669 | + * unlock_transaction |
|
1670 | + * |
|
1671 | + * @return void |
|
1672 | + * @throws EE_Error |
|
1673 | + * @throws ReflectionException |
|
1674 | + */ |
|
1675 | + public function unlock_transaction() |
|
1676 | + { |
|
1677 | + if ($this->checkout->transaction instanceof EE_Transaction) { |
|
1678 | + $this->checkout->transaction->unlock(); |
|
1679 | + } |
|
1680 | + } |
|
1681 | + |
|
1682 | + |
|
1683 | + /** |
|
1684 | + * _setup_redirect |
|
1685 | + * |
|
1686 | + * @return void |
|
1687 | + */ |
|
1688 | + private function _setup_redirect() |
|
1689 | + { |
|
1690 | + if ($this->checkout->continue_reg && $this->checkout->next_step instanceof EE_SPCO_Reg_Step) { |
|
1691 | + $this->checkout->redirect = true; |
|
1692 | + if (empty($this->checkout->redirect_url)) { |
|
1693 | + $this->checkout->redirect_url = $this->checkout->next_step->reg_step_url(); |
|
1694 | + } |
|
1695 | + $this->checkout->redirect_url = apply_filters( |
|
1696 | + 'FHEE__EED_Single_Page_Checkout___setup_redirect__checkout_redirect_url', |
|
1697 | + $this->checkout->redirect_url, |
|
1698 | + $this->checkout |
|
1699 | + ); |
|
1700 | + } |
|
1701 | + } |
|
1702 | + |
|
1703 | + |
|
1704 | + /** |
|
1705 | + * handle ajax message responses and redirects |
|
1706 | + * |
|
1707 | + * @return void |
|
1708 | + * @throws EE_Error |
|
1709 | + * @throws ReflectionException |
|
1710 | + */ |
|
1711 | + public function go_to_next_step() |
|
1712 | + { |
|
1713 | + if ($this->request->isAjax()) { |
|
1714 | + // capture contents of output buffer we started earlier in the request, and insert into JSON response |
|
1715 | + $this->checkout->json_response->set_unexpected_errors(ob_get_clean()); |
|
1716 | + } |
|
1717 | + $this->unlock_transaction(); |
|
1718 | + // just return for these conditions |
|
1719 | + if ( |
|
1720 | + $this->checkout->admin_request |
|
1721 | + || $this->checkout->action === 'redirect_form' |
|
1722 | + || $this->checkout->action === 'update_checkout' |
|
1723 | + ) { |
|
1724 | + return; |
|
1725 | + } |
|
1726 | + // AJAX response |
|
1727 | + $this->_handle_json_response(); |
|
1728 | + // redirect to next step or the Thank You page |
|
1729 | + $this->_handle_html_redirects(); |
|
1730 | + // hmmm... must be something wrong, so let's just display the form again ! |
|
1731 | + $this->_display_spco_reg_form(); |
|
1732 | + } |
|
1733 | + |
|
1734 | + |
|
1735 | + /** |
|
1736 | + * _handle_json_response |
|
1737 | + * |
|
1738 | + * @return void |
|
1739 | + * @throws EE_Error |
|
1740 | + */ |
|
1741 | + protected function _handle_json_response() |
|
1742 | + { |
|
1743 | + // if this is an ajax request |
|
1744 | + if ($this->request->isAjax()) { |
|
1745 | + $this->checkout->json_response->set_registration_time_limit( |
|
1746 | + $this->checkout->get_registration_time_limit() |
|
1747 | + ); |
|
1748 | + $this->checkout->json_response->set_payment_amount($this->checkout->amount_owing); |
|
1749 | + // just send the ajax ( |
|
1750 | + $json_response = apply_filters( |
|
1751 | + 'FHEE__EE_Single_Page_Checkout__JSON_response', |
|
1752 | + $this->checkout->json_response |
|
1753 | + ); |
|
1754 | + exit($json_response); |
|
1755 | + } |
|
1756 | + } |
|
1757 | + |
|
1758 | + |
|
1759 | + /** |
|
1760 | + * _handle_redirects |
|
1761 | + * |
|
1762 | + * @return void |
|
1763 | + */ |
|
1764 | + protected function _handle_html_redirects() |
|
1765 | + { |
|
1766 | + // going somewhere ? |
|
1767 | + if ($this->checkout->redirect && ! empty($this->checkout->redirect_url)) { |
|
1768 | + // store notices in a transient |
|
1769 | + EE_Error::get_notices(false, true); |
|
1770 | + wp_safe_redirect($this->checkout->redirect_url); |
|
1771 | + exit(); |
|
1772 | + } |
|
1773 | + } |
|
1774 | + |
|
1775 | + |
|
1776 | + /** |
|
1777 | + * set_checkout_anchor |
|
1778 | + * |
|
1779 | + * @return void |
|
1780 | + */ |
|
1781 | + public function set_checkout_anchor() |
|
1782 | + { |
|
1783 | + echo '<a id="checkout" style="float: left; margin-left: -999em;"></a>'; |
|
1784 | + } |
|
1785 | + |
|
1786 | + /** |
|
1787 | + * getRegistrationExpirationNotice |
|
1788 | + * |
|
1789 | + * @since 4.9.59.p |
|
1790 | + * @return string |
|
1791 | + */ |
|
1792 | + public static function getRegistrationExpirationNotice() |
|
1793 | + { |
|
1794 | + return sprintf( |
|
1795 | + esc_html__( |
|
1796 | + '%1$sWe\'re sorry, but your registration time has expired.%2$s%3$s%4$sIf you still wish to complete your registration, please return to the %5$sEvent List%6$sEvent List%7$s and reselect your tickets if available. Please accept our apologies for any inconvenience this may have caused.%8$s', |
|
1797 | + 'event_espresso' |
|
1798 | + ), |
|
1799 | + '<h4 class="important-notice">', |
|
1800 | + '</h4>', |
|
1801 | + '<br />', |
|
1802 | + '<p>', |
|
1803 | + '<a href="' . get_post_type_archive_link('espresso_events') . '" title="', |
|
1804 | + '">', |
|
1805 | + '</a>', |
|
1806 | + '</p>' |
|
1807 | + ); |
|
1808 | + } |
|
1809 | 1809 | } |
@@ -30,10 +30,10 @@ discard block |
||
30 | 30 | <label><?php esc_html_e('Amount Owing: ', 'event_espresso'); ?></label> |
31 | 31 | </td> |
32 | 32 | <td class="<?php echo sanitize_html_class( |
33 | - $transaction->paid() == $transaction->total() |
|
34 | - ? 'ee-transaction-paid' |
|
35 | - : 'ee-transaction-unpaid' |
|
36 | - ); ?>"> |
|
33 | + $transaction->paid() == $transaction->total() |
|
34 | + ? 'ee-transaction-paid' |
|
35 | + : 'ee-transaction-unpaid' |
|
36 | + ); ?>"> |
|
37 | 37 | <?php echo wp_kses(EEH_Template::format_currency($transaction->remaining()), AllowedTags::getAllowedTags()); ?> |
38 | 38 | </td> |
39 | 39 | </tr> |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | </td> |
44 | 44 | <td> |
45 | 45 | <?php $transaction->e_pretty_status(true); |
46 | - if ($show_try_pay_again_link && ! $transaction->is_completed()) { ?> |
|
46 | + if ($show_try_pay_again_link && ! $transaction->is_completed()) { ?> |
|
47 | 47 | <span class="small-text"> |
48 | 48 | <a href='<?php echo esc_url_raw($SPCO_payment_options_url) ?>'> |
49 | 49 | <?php esc_html_e('View Payment Options', 'event_espresso'); ?> |
@@ -61,9 +61,9 @@ discard block |
||
61 | 61 | </td> |
62 | 62 | </tr> |
63 | 63 | <?php do_action( |
64 | - 'AHEE__thank_you_page_transaction_details_template__after_transaction_table_row', |
|
65 | - $transaction |
|
66 | - ); ?> |
|
64 | + 'AHEE__thank_you_page_transaction_details_template__after_transaction_table_row', |
|
65 | + $transaction |
|
66 | + ); ?> |
|
67 | 67 | </tbody> |
68 | 68 | </table> |
69 | 69 |