@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
2 | - exit( 'No direct script access allowed' ); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | /** |
5 | 5 | * Event Espresso |
@@ -50,9 +50,9 @@ discard block |
||
50 | 50 | * date_format and the second value is the time format |
51 | 51 | * @return EE_Line_Item |
52 | 52 | */ |
53 | - public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) { |
|
54 | - $has_object = parent::_check_for_object( $props_n_values, __CLASS__, $timezone, $date_formats ); |
|
55 | - return $has_object ? $has_object : new self( $props_n_values, false, $timezone, $date_formats ); |
|
53 | + public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) { |
|
54 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
55 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | |
@@ -63,8 +63,8 @@ discard block |
||
63 | 63 | * the website will be used. |
64 | 64 | * @return EE_Line_Item |
65 | 65 | */ |
66 | - public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) { |
|
67 | - return new self( $props_n_values, TRUE, $timezone ); |
|
66 | + public static function new_instance_from_db($props_n_values = array(), $timezone = null) { |
|
67 | + return new self($props_n_values, TRUE, $timezone); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | |
@@ -75,10 +75,10 @@ discard block |
||
75 | 75 | * @param bool $bydb |
76 | 76 | * @param string $timezone |
77 | 77 | */ |
78 | - protected function __construct( $fieldValues = array(), $bydb = FALSE, $timezone = '' ) { |
|
79 | - parent::__construct( $fieldValues, $bydb, $timezone ); |
|
80 | - if ( ! $this->get( 'LIN_code' ) ) { |
|
81 | - $this->set_code( $this->generate_code() ); |
|
78 | + protected function __construct($fieldValues = array(), $bydb = FALSE, $timezone = '') { |
|
79 | + parent::__construct($fieldValues, $bydb, $timezone); |
|
80 | + if ( ! $this->get('LIN_code')) { |
|
81 | + $this->set_code($this->generate_code()); |
|
82 | 82 | } |
83 | 83 | } |
84 | 84 | |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | * @return int |
90 | 90 | */ |
91 | 91 | function ID() { |
92 | - return $this->get( 'LIN_ID' ); |
|
92 | + return $this->get('LIN_ID'); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | * @return int |
100 | 100 | */ |
101 | 101 | function TXN_ID() { |
102 | - return $this->get( 'TXN_ID' ); |
|
102 | + return $this->get('TXN_ID'); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | |
@@ -109,8 +109,8 @@ discard block |
||
109 | 109 | * @param int $TXN_ID |
110 | 110 | * @return boolean |
111 | 111 | */ |
112 | - function set_TXN_ID( $TXN_ID ) { |
|
113 | - $this->set( 'TXN_ID', $TXN_ID ); |
|
112 | + function set_TXN_ID($TXN_ID) { |
|
113 | + $this->set('TXN_ID', $TXN_ID); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | |
@@ -120,9 +120,9 @@ discard block |
||
120 | 120 | * @return string |
121 | 121 | */ |
122 | 122 | function name() { |
123 | - $name = $this->get( 'LIN_name' ); |
|
124 | - if( ! $name ){ |
|
125 | - $name = ucwords( str_replace( '-', ' ', $this->type() ) ); |
|
123 | + $name = $this->get('LIN_name'); |
|
124 | + if ( ! $name) { |
|
125 | + $name = ucwords(str_replace('-', ' ', $this->type())); |
|
126 | 126 | } |
127 | 127 | return $name; |
128 | 128 | } |
@@ -134,8 +134,8 @@ discard block |
||
134 | 134 | * @param string $name |
135 | 135 | * @return boolean |
136 | 136 | */ |
137 | - function set_name( $name ) { |
|
138 | - $this->set( 'LIN_name', $name ); |
|
137 | + function set_name($name) { |
|
138 | + $this->set('LIN_name', $name); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | * @return string |
146 | 146 | */ |
147 | 147 | function desc() { |
148 | - return $this->get( 'LIN_desc' ); |
|
148 | + return $this->get('LIN_desc'); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | |
@@ -155,8 +155,8 @@ discard block |
||
155 | 155 | * @param string $desc |
156 | 156 | * @return boolean |
157 | 157 | */ |
158 | - function set_desc( $desc ) { |
|
159 | - $this->set( 'LIN_desc', $desc ); |
|
158 | + function set_desc($desc) { |
|
159 | + $this->set('LIN_desc', $desc); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | * @return int |
167 | 167 | */ |
168 | 168 | function quantity() { |
169 | - return $this->get( 'LIN_quantity' ); |
|
169 | + return $this->get('LIN_quantity'); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | |
@@ -176,8 +176,8 @@ discard block |
||
176 | 176 | * @param int $quantity |
177 | 177 | * @return boolean |
178 | 178 | */ |
179 | - function set_quantity( $quantity ) { |
|
180 | - $this->set( 'LIN_quantity', $quantity ); |
|
179 | + function set_quantity($quantity) { |
|
180 | + $this->set('LIN_quantity', $quantity); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | * @return string |
188 | 188 | */ |
189 | 189 | function OBJ_ID() { |
190 | - return $this->get( 'OBJ_ID' ); |
|
190 | + return $this->get('OBJ_ID'); |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | |
@@ -197,8 +197,8 @@ discard block |
||
197 | 197 | * @param string $item_id |
198 | 198 | * @return boolean |
199 | 199 | */ |
200 | - function set_OBJ_ID( $item_id ) { |
|
201 | - $this->set( 'OBJ_ID', $item_id ); |
|
200 | + function set_OBJ_ID($item_id) { |
|
201 | + $this->set('OBJ_ID', $item_id); |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | * @return string |
209 | 209 | */ |
210 | 210 | function OBJ_type() { |
211 | - return $this->get( 'OBJ_type' ); |
|
211 | + return $this->get('OBJ_type'); |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | |
@@ -218,8 +218,8 @@ discard block |
||
218 | 218 | * @param string $OBJ_type |
219 | 219 | * @return boolean |
220 | 220 | */ |
221 | - function set_OBJ_type( $OBJ_type ) { |
|
222 | - $this->set( 'OBJ_type', $OBJ_type ); |
|
221 | + function set_OBJ_type($OBJ_type) { |
|
222 | + $this->set('OBJ_type', $OBJ_type); |
|
223 | 223 | } |
224 | 224 | |
225 | 225 | |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | * @return float |
230 | 230 | */ |
231 | 231 | function unit_price() { |
232 | - return $this->get( 'LIN_unit_price' ); |
|
232 | + return $this->get('LIN_unit_price'); |
|
233 | 233 | } |
234 | 234 | |
235 | 235 | |
@@ -239,8 +239,8 @@ discard block |
||
239 | 239 | * @param float $unit_price |
240 | 240 | * @return boolean |
241 | 241 | */ |
242 | - function set_unit_price( $unit_price ) { |
|
243 | - $this->set( 'LIN_unit_price', $unit_price ); |
|
242 | + function set_unit_price($unit_price) { |
|
243 | + $this->set('LIN_unit_price', $unit_price); |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | |
@@ -251,19 +251,19 @@ discard block |
||
251 | 251 | * @return boolean |
252 | 252 | */ |
253 | 253 | function is_percent() { |
254 | - if( $this->is_tax_sub_total() ) { |
|
254 | + if ($this->is_tax_sub_total()) { |
|
255 | 255 | //tax subtotals HAVE a percent on them, that percentage only applies |
256 | 256 | //to taxable items, so its' an exception. Treat it like a flat line item |
257 | 257 | return false; |
258 | 258 | } |
259 | - $unit_price = abs( $this->get( 'LIN_unit_price' ) ); |
|
260 | - $percent = abs( $this->get( 'LIN_percent' ) ); |
|
261 | - if ( $unit_price < .001 && $percent ) { |
|
259 | + $unit_price = abs($this->get('LIN_unit_price')); |
|
260 | + $percent = abs($this->get('LIN_percent')); |
|
261 | + if ($unit_price < .001 && $percent) { |
|
262 | 262 | return TRUE; |
263 | - } elseif ( $unit_price >= .001 && !$percent ) { |
|
263 | + } elseif ($unit_price >= .001 && ! $percent) { |
|
264 | 264 | return FALSE; |
265 | - } elseif ( $unit_price >= .001 && $percent ) { |
|
266 | - throw new EE_Error( sprintf( __( "A Line Item can not have a unit price of (%s) AND a percent (%s)!", "event_espresso" ), $unit_price, $percent ) ); |
|
265 | + } elseif ($unit_price >= .001 && $percent) { |
|
266 | + throw new EE_Error(sprintf(__("A Line Item can not have a unit price of (%s) AND a percent (%s)!", "event_espresso"), $unit_price, $percent)); |
|
267 | 267 | } else { |
268 | 268 | // if they're both 0, assume its not a percent item |
269 | 269 | return FALSE; |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | * @return float |
278 | 278 | */ |
279 | 279 | function percent() { |
280 | - return $this->get( 'LIN_percent' ); |
|
280 | + return $this->get('LIN_percent'); |
|
281 | 281 | } |
282 | 282 | |
283 | 283 | |
@@ -287,8 +287,8 @@ discard block |
||
287 | 287 | * @param float $percent |
288 | 288 | * @return boolean |
289 | 289 | */ |
290 | - function set_percent( $percent ) { |
|
291 | - $this->set( 'LIN_percent', $percent ); |
|
290 | + function set_percent($percent) { |
|
291 | + $this->set('LIN_percent', $percent); |
|
292 | 292 | } |
293 | 293 | |
294 | 294 | |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | * @return float |
299 | 299 | */ |
300 | 300 | function total() { |
301 | - return $this->get( 'LIN_total' ); |
|
301 | + return $this->get('LIN_total'); |
|
302 | 302 | } |
303 | 303 | |
304 | 304 | |
@@ -308,8 +308,8 @@ discard block |
||
308 | 308 | * @param float $total |
309 | 309 | * @return boolean |
310 | 310 | */ |
311 | - function set_total( $total ) { |
|
312 | - $this->set( 'LIN_total', $total ); |
|
311 | + function set_total($total) { |
|
312 | + $this->set('LIN_total', $total); |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | * @return int |
320 | 320 | */ |
321 | 321 | function order() { |
322 | - return $this->get( 'LIN_order' ); |
|
322 | + return $this->get('LIN_order'); |
|
323 | 323 | } |
324 | 324 | |
325 | 325 | |
@@ -328,8 +328,8 @@ discard block |
||
328 | 328 | * Sets order |
329 | 329 | * @param int $order |
330 | 330 | */ |
331 | - function set_order( $order ) { |
|
332 | - $this->set( 'LIN_order', $order ); |
|
331 | + function set_order($order) { |
|
332 | + $this->set('LIN_order', $order); |
|
333 | 333 | } |
334 | 334 | |
335 | 335 | |
@@ -339,7 +339,7 @@ discard block |
||
339 | 339 | * @return int |
340 | 340 | */ |
341 | 341 | function parent_ID() { |
342 | - return $this->get( 'LIN_parent' ); |
|
342 | + return $this->get('LIN_parent'); |
|
343 | 343 | } |
344 | 344 | |
345 | 345 | |
@@ -349,8 +349,8 @@ discard block |
||
349 | 349 | * @param int $parent |
350 | 350 | * @return boolean |
351 | 351 | */ |
352 | - function set_parent_ID( $parent ) { |
|
353 | - $this->set( 'LIN_parent', $parent ); |
|
352 | + function set_parent_ID($parent) { |
|
353 | + $this->set('LIN_parent', $parent); |
|
354 | 354 | } |
355 | 355 | |
356 | 356 | |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | * @return string |
361 | 361 | */ |
362 | 362 | function type() { |
363 | - return $this->get( 'LIN_type' ); |
|
363 | + return $this->get('LIN_type'); |
|
364 | 364 | } |
365 | 365 | |
366 | 366 | |
@@ -370,8 +370,8 @@ discard block |
||
370 | 370 | * @param string $type |
371 | 371 | * @return boolean |
372 | 372 | */ |
373 | - function set_type( $type ) { |
|
374 | - $this->set( 'LIN_type', $type ); |
|
373 | + function set_type($type) { |
|
374 | + $this->set('LIN_type', $type); |
|
375 | 375 | } |
376 | 376 | |
377 | 377 | |
@@ -384,8 +384,8 @@ discard block |
||
384 | 384 | * @return EE_Line_Item |
385 | 385 | */ |
386 | 386 | public function parent() { |
387 | - if( $this->ID() ) { |
|
388 | - return $this->get_model()->get_one_by_ID( $this->parent_ID() ); |
|
387 | + if ($this->ID()) { |
|
388 | + return $this->get_model()->get_one_by_ID($this->parent_ID()); |
|
389 | 389 | } else { |
390 | 390 | return $this->_parent; |
391 | 391 | } |
@@ -398,13 +398,13 @@ discard block |
||
398 | 398 | * @return EE_Line_Item[] |
399 | 399 | */ |
400 | 400 | public function children() { |
401 | - if ( $this->ID() ) { |
|
401 | + if ($this->ID()) { |
|
402 | 402 | return $this->get_model()->get_all( |
403 | 403 | array( |
404 | - array( 'LIN_parent' => $this->ID() ), |
|
405 | - 'order_by' => array( 'LIN_order' => 'ASC' ) ) ); |
|
404 | + array('LIN_parent' => $this->ID()), |
|
405 | + 'order_by' => array('LIN_order' => 'ASC') ) ); |
|
406 | 406 | } else { |
407 | - if ( ! is_array( $this->_children ) ) { |
|
407 | + if ( ! is_array($this->_children)) { |
|
408 | 408 | $this->_children = array(); |
409 | 409 | } |
410 | 410 | return $this->_children; |
@@ -418,7 +418,7 @@ discard block |
||
418 | 418 | * @return string |
419 | 419 | */ |
420 | 420 | function code() { |
421 | - return $this->get( 'LIN_code' ); |
|
421 | + return $this->get('LIN_code'); |
|
422 | 422 | } |
423 | 423 | |
424 | 424 | |
@@ -428,8 +428,8 @@ discard block |
||
428 | 428 | * @param string $code |
429 | 429 | * @return boolean |
430 | 430 | */ |
431 | - function set_code( $code ) { |
|
432 | - $this->set( 'LIN_code', $code ); |
|
431 | + function set_code($code) { |
|
432 | + $this->set('LIN_code', $code); |
|
433 | 433 | } |
434 | 434 | |
435 | 435 | |
@@ -439,7 +439,7 @@ discard block |
||
439 | 439 | * @return boolean |
440 | 440 | */ |
441 | 441 | function is_taxable() { |
442 | - return $this->get( 'LIN_is_taxable' ); |
|
442 | + return $this->get('LIN_is_taxable'); |
|
443 | 443 | } |
444 | 444 | |
445 | 445 | |
@@ -449,8 +449,8 @@ discard block |
||
449 | 449 | * @param boolean $is_taxable |
450 | 450 | * @return boolean |
451 | 451 | */ |
452 | - function set_is_taxable( $is_taxable ) { |
|
453 | - $this->set( 'LIN_is_taxable', $is_taxable ); |
|
452 | + function set_is_taxable($is_taxable) { |
|
453 | + $this->set('LIN_is_taxable', $is_taxable); |
|
454 | 454 | } |
455 | 455 | |
456 | 456 | |
@@ -465,7 +465,7 @@ discard block |
||
465 | 465 | */ |
466 | 466 | function get_object() { |
467 | 467 | $model_name_of_related_obj = $this->OBJ_type(); |
468 | - return $this->get_model()->has_relation( $model_name_of_related_obj ) ? $this->get_first_related( $model_name_of_related_obj ) : NULL; |
|
468 | + return $this->get_model()->has_relation($model_name_of_related_obj) ? $this->get_first_related($model_name_of_related_obj) : NULL; |
|
469 | 469 | } |
470 | 470 | |
471 | 471 | |
@@ -476,11 +476,11 @@ discard block |
||
476 | 476 | * @param array $query_params |
477 | 477 | * @return EE_Ticket |
478 | 478 | */ |
479 | - function ticket( $query_params = array() ) { |
|
479 | + function ticket($query_params = array()) { |
|
480 | 480 | //we're going to assume that when this method is called we always want to receive the attached ticket EVEN if that ticket is archived. This can be overridden via the incoming $query_params argument |
481 | - $remove_defaults = array( 'default_where_conditions' => 'none' ); |
|
482 | - $query_params = array_merge( $remove_defaults, $query_params ); |
|
483 | - return $this->get_first_related( 'Ticket', $query_params ); |
|
481 | + $remove_defaults = array('default_where_conditions' => 'none'); |
|
482 | + $query_params = array_merge($remove_defaults, $query_params); |
|
483 | + return $this->get_first_related('Ticket', $query_params); |
|
484 | 484 | } |
485 | 485 | |
486 | 486 | |
@@ -490,11 +490,11 @@ discard block |
||
490 | 490 | * @return EE_Datetime | NULL |
491 | 491 | */ |
492 | 492 | function get_ticket_datetime() { |
493 | - if ( $this->OBJ_type() === 'Ticket' ) { |
|
493 | + if ($this->OBJ_type() === 'Ticket') { |
|
494 | 494 | $ticket = $this->ticket(); |
495 | - if ( $ticket instanceof EE_Ticket ) { |
|
495 | + if ($ticket instanceof EE_Ticket) { |
|
496 | 496 | $datetime = $ticket->first_datetime(); |
497 | - if ( $datetime instanceof EE_Datetime ) { |
|
497 | + if ($datetime instanceof EE_Datetime) { |
|
498 | 498 | return $datetime; |
499 | 499 | } |
500 | 500 | } |
@@ -510,9 +510,9 @@ discard block |
||
510 | 510 | * @return string |
511 | 511 | */ |
512 | 512 | function ticket_event_name() { |
513 | - $event_name = __( "Unknown", "event_espresso" ); |
|
513 | + $event_name = __("Unknown", "event_espresso"); |
|
514 | 514 | $event = $this->ticket_event(); |
515 | - if ( $event instanceof EE_Event ) { |
|
515 | + if ($event instanceof EE_Event) { |
|
516 | 516 | $event_name = $event->name(); |
517 | 517 | } |
518 | 518 | return $event_name; |
@@ -526,9 +526,9 @@ discard block |
||
526 | 526 | function ticket_event() { |
527 | 527 | $event = null; |
528 | 528 | $ticket = $this->ticket(); |
529 | - if ( $ticket instanceof EE_Ticket ) { |
|
529 | + if ($ticket instanceof EE_Ticket) { |
|
530 | 530 | $datetime = $ticket->first_datetime(); |
531 | - if ( $datetime instanceof EE_Datetime ) { |
|
531 | + if ($datetime instanceof EE_Datetime) { |
|
532 | 532 | $event = $datetime->event(); |
533 | 533 | } |
534 | 534 | } |
@@ -543,11 +543,11 @@ discard block |
||
543 | 543 | * @param string $time_format |
544 | 544 | * @return string |
545 | 545 | */ |
546 | - function ticket_datetime_start( $date_format = '', $time_format = '' ) { |
|
547 | - $first_datetime_string = __( "Unknown", "event_espresso" ); |
|
546 | + function ticket_datetime_start($date_format = '', $time_format = '') { |
|
547 | + $first_datetime_string = __("Unknown", "event_espresso"); |
|
548 | 548 | $datetime = $this->get_ticket_datetime(); |
549 | - if ( $datetime ) { |
|
550 | - $first_datetime_string = $datetime->start_date_and_time( $date_format, $time_format ); |
|
549 | + if ($datetime) { |
|
550 | + $first_datetime_string = $datetime->start_date_and_time($date_format, $time_format); |
|
551 | 551 | } |
552 | 552 | return $first_datetime_string; |
553 | 553 | } |
@@ -562,26 +562,26 @@ discard block |
||
562 | 562 | * @return bool success |
563 | 563 | * @throws \EE_Error |
564 | 564 | */ |
565 | - function add_child_line_item( EEI_Line_Item $line_item, $set_order = true ) { |
|
565 | + function add_child_line_item(EEI_Line_Item $line_item, $set_order = true) { |
|
566 | 566 | // should we calculate the LIN_order for this line item ? |
567 | - if ( $set_order || $line_item->order() === null ) { |
|
568 | - $line_item->set_order( count( $this->children() ) ); |
|
567 | + if ($set_order || $line_item->order() === null) { |
|
568 | + $line_item->set_order(count($this->children())); |
|
569 | 569 | } |
570 | - if ( $this->ID() ) { |
|
570 | + if ($this->ID()) { |
|
571 | 571 | //check for any duplicate line items (with the same code), if so, this replaces it |
572 | - $line_item_with_same_code = $this->get_child_line_item( $line_item->code() ); |
|
573 | - if( $line_item_with_same_code instanceof EE_Line_Item && $line_item_with_same_code !== $line_item ) { |
|
574 | - $this->delete_child_line_item( $line_item_with_same_code->code() ); |
|
572 | + $line_item_with_same_code = $this->get_child_line_item($line_item->code()); |
|
573 | + if ($line_item_with_same_code instanceof EE_Line_Item && $line_item_with_same_code !== $line_item) { |
|
574 | + $this->delete_child_line_item($line_item_with_same_code->code()); |
|
575 | 575 | } |
576 | - $line_item->set_parent_ID( $this->ID() ); |
|
577 | - if( $this->TXN_ID() ){ |
|
578 | - $line_item->set_TXN_ID( $this->TXN_ID() ); |
|
576 | + $line_item->set_parent_ID($this->ID()); |
|
577 | + if ($this->TXN_ID()) { |
|
578 | + $line_item->set_TXN_ID($this->TXN_ID()); |
|
579 | 579 | } |
580 | 580 | return $line_item->save(); |
581 | 581 | } else { |
582 | - $this->_children[ $line_item->code() ] = $line_item; |
|
583 | - if( $line_item->parent() != $this ) { |
|
584 | - $line_item->set_parent( $this ); |
|
582 | + $this->_children[$line_item->code()] = $line_item; |
|
583 | + if ($line_item->parent() != $this) { |
|
584 | + $line_item->set_parent($this); |
|
585 | 585 | } |
586 | 586 | return TRUE; |
587 | 587 | } |
@@ -595,16 +595,16 @@ discard block |
||
595 | 595 | * @param EE_Line_Item $line_item |
596 | 596 | * |
597 | 597 | */ |
598 | - public function set_parent( $line_item ) { |
|
599 | - if ( $this->ID() ) { |
|
600 | - if( ! $line_item->ID() ) { |
|
598 | + public function set_parent($line_item) { |
|
599 | + if ($this->ID()) { |
|
600 | + if ( ! $line_item->ID()) { |
|
601 | 601 | $line_item->save(); |
602 | 602 | } |
603 | - $this->set_parent_ID( $line_item->ID() ); |
|
603 | + $this->set_parent_ID($line_item->ID()); |
|
604 | 604 | $this->save(); |
605 | 605 | } else { |
606 | 606 | $this->_parent = $line_item; |
607 | - $this->set_parent_ID( $line_item->ID() ); |
|
607 | + $this->set_parent_ID($line_item->ID()); |
|
608 | 608 | } |
609 | 609 | } |
610 | 610 | |
@@ -617,11 +617,11 @@ discard block |
||
617 | 617 | * @param string $code |
618 | 618 | * @return EE_Line_Item |
619 | 619 | */ |
620 | - function get_child_line_item( $code ) { |
|
621 | - if ( $this->ID() ) { |
|
622 | - return $this->get_model()->get_one( array( array( 'LIN_parent' => $this->ID(), 'LIN_code' => $code ) ) ); |
|
620 | + function get_child_line_item($code) { |
|
621 | + if ($this->ID()) { |
|
622 | + return $this->get_model()->get_one(array(array('LIN_parent' => $this->ID(), 'LIN_code' => $code))); |
|
623 | 623 | } else { |
624 | - return isset( $this->_children[ $code ] ) ? $this->_children[ $code ] : null; |
|
624 | + return isset($this->_children[$code]) ? $this->_children[$code] : null; |
|
625 | 625 | } |
626 | 626 | } |
627 | 627 | |
@@ -632,10 +632,10 @@ discard block |
||
632 | 632 | * @return int |
633 | 633 | */ |
634 | 634 | function delete_children_line_items() { |
635 | - if ( $this->ID() ) { |
|
636 | - return $this->get_model()->delete( array( array( 'LIN_parent' => $this->ID() ) ) ); |
|
635 | + if ($this->ID()) { |
|
636 | + return $this->get_model()->delete(array(array('LIN_parent' => $this->ID()))); |
|
637 | 637 | } else { |
638 | - $count = count( $this->_children ); |
|
638 | + $count = count($this->_children); |
|
639 | 639 | $this->_children = array(); |
640 | 640 | return $count; |
641 | 641 | } |
@@ -652,25 +652,25 @@ discard block |
||
652 | 652 | * @param bool $stop_search_once_found |
653 | 653 | * @return int count of items deleted (or simply removed from the line item's cache, if not has not been saved to the DB yet) |
654 | 654 | */ |
655 | - function delete_child_line_item( $code, $stop_search_once_found = true ) { |
|
656 | - if ( $this->ID() ) { |
|
655 | + function delete_child_line_item($code, $stop_search_once_found = true) { |
|
656 | + if ($this->ID()) { |
|
657 | 657 | $items_deleted = 0; |
658 | - if( $this->code() == $code ) { |
|
659 | - $items_deleted += EEH_Line_Item::delete_all_child_items( $this ); |
|
660 | - $items_deleted += intval( $this->delete() ); |
|
661 | - if( $stop_search_once_found ){ |
|
658 | + if ($this->code() == $code) { |
|
659 | + $items_deleted += EEH_Line_Item::delete_all_child_items($this); |
|
660 | + $items_deleted += intval($this->delete()); |
|
661 | + if ($stop_search_once_found) { |
|
662 | 662 | return $items_deleted; |
663 | 663 | } |
664 | 664 | } |
665 | - foreach( $this->children() as $child_line_item ) { |
|
666 | - $items_deleted += $child_line_item->delete_child_line_item( $code, $stop_search_once_found ); |
|
665 | + foreach ($this->children() as $child_line_item) { |
|
666 | + $items_deleted += $child_line_item->delete_child_line_item($code, $stop_search_once_found); |
|
667 | 667 | } |
668 | 668 | return $items_deleted; |
669 | 669 | } else { |
670 | - if( isset( $this->_children[ $code ] ) ) { |
|
671 | - unset( $this->_children[ $code ] ); |
|
670 | + if (isset($this->_children[$code])) { |
|
671 | + unset($this->_children[$code]); |
|
672 | 672 | return 1; |
673 | - }else{ |
|
673 | + } else { |
|
674 | 674 | return 0; |
675 | 675 | } |
676 | 676 | } |
@@ -683,9 +683,9 @@ discard block |
||
683 | 683 | * @return boolean |
684 | 684 | */ |
685 | 685 | public function delete_if_childless_subtotal() { |
686 | - if( $this->ID() && |
|
686 | + if ($this->ID() && |
|
687 | 687 | $this->type() == EEM_Line_Item::type_sub_total && |
688 | - ! $this->children() ) { |
|
688 | + ! $this->children()) { |
|
689 | 689 | return $this->delete(); |
690 | 690 | } else { |
691 | 691 | return false; |
@@ -700,7 +700,7 @@ discard block |
||
700 | 700 | */ |
701 | 701 | function generate_code() { |
702 | 702 | // each line item in the cart requires a unique identifier |
703 | - return md5( $this->get( 'OBJ_type' ) . $this->get( 'OBJ_ID' ) . microtime() ); |
|
703 | + return md5($this->get('OBJ_type').$this->get('OBJ_ID').microtime()); |
|
704 | 704 | } |
705 | 705 | |
706 | 706 | |
@@ -764,7 +764,7 @@ discard block |
||
764 | 764 | * @return string like '2, 004.00', formatted according to the localized currency |
765 | 765 | */ |
766 | 766 | function unit_price_no_code() { |
767 | - return $this->get_pretty( 'LIN_unit_price', 'no_currency_code' ); |
|
767 | + return $this->get_pretty('LIN_unit_price', 'no_currency_code'); |
|
768 | 768 | } |
769 | 769 | |
770 | 770 | |
@@ -774,7 +774,7 @@ discard block |
||
774 | 774 | * @return string like '2, 004.00', formatted according to the localized currency |
775 | 775 | */ |
776 | 776 | function total_no_code() { |
777 | - return $this->get_pretty( 'LIN_total', 'no_currency_code' ); |
|
777 | + return $this->get_pretty('LIN_total', 'no_currency_code'); |
|
778 | 778 | } |
779 | 779 | |
780 | 780 | |
@@ -793,17 +793,17 @@ discard block |
||
793 | 793 | |
794 | 794 | $total = $pre_tax_total + $tax_total; |
795 | 795 | // no negative totals plz |
796 | - $total = max( $total, 0 ); |
|
797 | - $this->set_total( $total ); |
|
796 | + $total = max($total, 0); |
|
797 | + $this->set_total($total); |
|
798 | 798 | //only update the related transaction's total |
799 | 799 | //if we intend to save this line item and its a grand total |
800 | - if( |
|
800 | + if ( |
|
801 | 801 | $this->allow_persist() && |
802 | 802 | $this->type() == EEM_Line_Item::type_total && |
803 | 803 | $this->transaction() instanceof EE_Transaction |
804 | - ){ |
|
805 | - $this->transaction()->set_total( $total ); |
|
806 | - if ( $this->transaction()->ID() ) { |
|
804 | + ) { |
|
805 | + $this->transaction()->set_total($total); |
|
806 | + if ($this->transaction()->ID()) { |
|
807 | 807 | $this->transaction()->save(); |
808 | 808 | } |
809 | 809 | } |
@@ -824,42 +824,42 @@ discard block |
||
824 | 824 | $total = 0; |
825 | 825 | $my_children = $this->children(); |
826 | 826 | //completely ignore tax and tax sub-totals when calculating the pre-tax-total |
827 | - if ( $this->is_tax_sub_total() || $this->is_tax() ) { |
|
827 | + if ($this->is_tax_sub_total() || $this->is_tax()) { |
|
828 | 828 | return 0; |
829 | 829 | } elseif ( |
830 | - ( $this->is_sub_line_item() || $this->is_line_item() ) |
|
831 | - && empty( $my_children ) |
|
830 | + ($this->is_sub_line_item() || $this->is_line_item()) |
|
831 | + && empty($my_children) |
|
832 | 832 | ) { |
833 | 833 | $total = $this->unit_price() * $this->quantity(); |
834 | - } elseif( $this->is_sub_total() || $this->is_total() ) { |
|
835 | - $total = $this->_recalculate_pretax_total_for_subtotal( $total, $my_children ); |
|
836 | - } elseif ( $this->is_line_item() && ! empty( $my_children ) ) { |
|
837 | - $total = $this->_recalculate_pretax_total_for_line_item( $total, $my_children ); |
|
834 | + } elseif ($this->is_sub_total() || $this->is_total()) { |
|
835 | + $total = $this->_recalculate_pretax_total_for_subtotal($total, $my_children); |
|
836 | + } elseif ($this->is_line_item() && ! empty($my_children)) { |
|
837 | + $total = $this->_recalculate_pretax_total_for_line_item($total, $my_children); |
|
838 | 838 | } |
839 | 839 | //ensure all non-line items and non-sub-line-items have a quantity of 1 |
840 | - if( ! $this->is_line_item() && ! $this->is_sub_line_item() ) { |
|
841 | - $this->set_quantity( 1 ); |
|
842 | - if( ! $this->is_percent() ) { |
|
843 | - $this->set_unit_price( $this->total() ); |
|
840 | + if ( ! $this->is_line_item() && ! $this->is_sub_line_item()) { |
|
841 | + $this->set_quantity(1); |
|
842 | + if ( ! $this->is_percent()) { |
|
843 | + $this->set_unit_price($this->total()); |
|
844 | 844 | } |
845 | 845 | } |
846 | 846 | |
847 | 847 | //we don't want to bother saving grand totals, because that needs to factor in taxes anyways |
848 | 848 | //so it ought to be |
849 | - if( ! $this->is_total() ) { |
|
850 | - $this->set_total( $total ); |
|
849 | + if ( ! $this->is_total()) { |
|
850 | + $this->set_total($total); |
|
851 | 851 | //if not a percent line item, make sure we keep the unit price in sync |
852 | - if( |
|
852 | + if ( |
|
853 | 853 | $this->is_line_item() && |
854 | - ! empty( $my_children ) && |
|
854 | + ! empty($my_children) && |
|
855 | 855 | ! $this->is_percent() |
856 | 856 | ) { |
857 | - if( $this->quantity() === 0 ){ |
|
857 | + if ($this->quantity() === 0) { |
|
858 | 858 | $new_unit_price = 0; |
859 | 859 | } else { |
860 | 860 | $new_unit_price = $this->total() / $this->quantity(); |
861 | 861 | } |
862 | - $this->set_unit_price( $new_unit_price ); |
|
862 | + $this->set_unit_price($new_unit_price); |
|
863 | 863 | } |
864 | 864 | $this->maybe_save(); |
865 | 865 | } |
@@ -875,14 +875,14 @@ discard block |
||
875 | 875 | * @param EE_Line_Item[] $my_children |
876 | 876 | * @return float |
877 | 877 | */ |
878 | - protected function _recalculate_pretax_total_for_subtotal( $calculated_total_so_far, $my_children = null ) { |
|
879 | - if( $my_children === null ) { |
|
878 | + protected function _recalculate_pretax_total_for_subtotal($calculated_total_so_far, $my_children = null) { |
|
879 | + if ($my_children === null) { |
|
880 | 880 | $my_children = $this->children(); |
881 | 881 | } |
882 | 882 | //get the total of all its children |
883 | - foreach ( $my_children as $child_line_item ) { |
|
884 | - if ( $child_line_item instanceof EE_Line_Item ) { |
|
885 | - if ( $child_line_item->is_percent() ) { |
|
883 | + foreach ($my_children as $child_line_item) { |
|
884 | + if ($child_line_item instanceof EE_Line_Item) { |
|
885 | + if ($child_line_item->is_percent()) { |
|
886 | 886 | |
887 | 887 | //round as we go so that the line items add up ok |
888 | 888 | $percent_total = round( |
@@ -890,25 +890,25 @@ discard block |
||
890 | 890 | EE_Registry::instance()->CFG->currency->dec_plc |
891 | 891 | ); |
892 | 892 | |
893 | - $child_line_item->set_total( $percent_total ); |
|
893 | + $child_line_item->set_total($percent_total); |
|
894 | 894 | //so far all percent line items should have a quantity of 1 |
895 | 895 | //(ie, no double percent discounts. Although that might be requested someday) |
896 | - $child_line_item->set_quantity( 1 ); |
|
896 | + $child_line_item->set_quantity(1); |
|
897 | 897 | $child_line_item->maybe_save(); |
898 | 898 | $calculated_total_so_far += $percent_total; |
899 | 899 | } else { |
900 | 900 | //verify flat sub-line-item quantities match their parent |
901 | - if( $child_line_item->is_sub_line_item() ) { |
|
902 | - $child_line_item->set_quantity( $this->quantity() ); |
|
901 | + if ($child_line_item->is_sub_line_item()) { |
|
902 | + $child_line_item->set_quantity($this->quantity()); |
|
903 | 903 | } |
904 | 904 | $calculated_total_so_far += $child_line_item->recalculate_pre_tax_total(); |
905 | 905 | } |
906 | 906 | } |
907 | 907 | } |
908 | 908 | |
909 | - if( $this->is_sub_total() ){ |
|
909 | + if ($this->is_sub_total()) { |
|
910 | 910 | // no negative totals plz |
911 | - $calculated_total_so_far = max( $calculated_total_so_far, 0 ); |
|
911 | + $calculated_total_so_far = max($calculated_total_so_far, 0); |
|
912 | 912 | } |
913 | 913 | return $calculated_total_so_far; |
914 | 914 | } |
@@ -922,8 +922,8 @@ discard block |
||
922 | 922 | * @param EE_Line_Item[] $my_children |
923 | 923 | * @return float |
924 | 924 | */ |
925 | - protected function _recalculate_pretax_total_for_line_item( $calculated_total_so_far, $my_children = null ) { |
|
926 | - if( $my_children === null ) { |
|
925 | + protected function _recalculate_pretax_total_for_line_item($calculated_total_so_far, $my_children = null) { |
|
926 | + if ($my_children === null) { |
|
927 | 927 | $my_children = $this->children(); |
928 | 928 | } |
929 | 929 | //we need to keep track of the running total for a single item, |
@@ -931,9 +931,9 @@ discard block |
||
931 | 931 | $unit_price_for_total = 0; |
932 | 932 | $quantity_for_total = 1; |
933 | 933 | //get the total of all its children |
934 | - foreach ( $my_children as $child_line_item ) { |
|
935 | - if ( $child_line_item instanceof EE_Line_Item ) { |
|
936 | - if ( $child_line_item->is_percent() ) { |
|
934 | + foreach ($my_children as $child_line_item) { |
|
935 | + if ($child_line_item instanceof EE_Line_Item) { |
|
936 | + if ($child_line_item->is_percent()) { |
|
937 | 937 | //it should be the unit-price-so-far multiplied by teh percent multiplied by the quantity |
938 | 938 | //not total multiplied by percent, because that ignores rounding along-the-way |
939 | 939 | $percent_unit_price = round( |
@@ -941,17 +941,17 @@ discard block |
||
941 | 941 | EE_Registry::instance()->CFG->currency->dec_plc |
942 | 942 | ); |
943 | 943 | $percent_total = $percent_unit_price * $quantity_for_total; |
944 | - $child_line_item->set_total( $percent_total ); |
|
944 | + $child_line_item->set_total($percent_total); |
|
945 | 945 | //so far all percent line items should have a quantity of 1 |
946 | 946 | //(ie, no double percent discounts. Although that might be requested someday) |
947 | - $child_line_item->set_quantity( 1 ); |
|
947 | + $child_line_item->set_quantity(1); |
|
948 | 948 | $child_line_item->maybe_save(); |
949 | 949 | $calculated_total_so_far += $percent_total; |
950 | 950 | $unit_price_for_total += $percent_unit_price; |
951 | 951 | } else { |
952 | 952 | //verify flat sub-line-item quantities match their parent |
953 | - if( $child_line_item->is_sub_line_item() ) { |
|
954 | - $child_line_item->set_quantity( $this->quantity() ); |
|
953 | + if ($child_line_item->is_sub_line_item()) { |
|
954 | + $child_line_item->set_quantity($this->quantity()); |
|
955 | 955 | } |
956 | 956 | $quantity_for_total = $child_line_item->quantity(); |
957 | 957 | $calculated_total_so_far += $child_line_item->recalculate_pre_tax_total(); |
@@ -975,10 +975,10 @@ discard block |
||
975 | 975 | //calculate the pretax total |
976 | 976 | $taxable_total = $this->taxable_total(); |
977 | 977 | $tax_total = 0; |
978 | - foreach ( $taxes as $tax ) { |
|
978 | + foreach ($taxes as $tax) { |
|
979 | 979 | $total_on_this_tax = $taxable_total * $tax->percent() / 100; |
980 | 980 | //remember the total on this line item |
981 | - $tax->set_total( $total_on_this_tax ); |
|
981 | + $tax->set_total($total_on_this_tax); |
|
982 | 982 | $tax_total += $tax->total(); |
983 | 983 | } |
984 | 984 | $this->_recalculate_tax_sub_total(); |
@@ -992,21 +992,21 @@ discard block |
||
992 | 992 | * @return void |
993 | 993 | */ |
994 | 994 | private function _recalculate_tax_sub_total() { |
995 | - if ( $this->is_tax_sub_total() ) { |
|
995 | + if ($this->is_tax_sub_total()) { |
|
996 | 996 | $total = 0; |
997 | 997 | $total_percent = 0; |
998 | 998 | //simply loop through all its children (which should be taxes) and sum their total |
999 | - foreach ( $this->children() as $child_tax ) { |
|
1000 | - if ( $child_tax instanceof EE_Line_Item ) { |
|
999 | + foreach ($this->children() as $child_tax) { |
|
1000 | + if ($child_tax instanceof EE_Line_Item) { |
|
1001 | 1001 | $total += $child_tax->total(); |
1002 | 1002 | $total_percent += $child_tax->percent(); |
1003 | 1003 | } |
1004 | 1004 | } |
1005 | - $this->set_total( $total ); |
|
1006 | - $this->set_percent( $total_percent ); |
|
1007 | - } elseif ( $this->is_total() ) { |
|
1008 | - foreach ( $this->children() as $maybe_tax_subtotal ) { |
|
1009 | - if ( $maybe_tax_subtotal instanceof EE_Line_Item ) { |
|
1005 | + $this->set_total($total); |
|
1006 | + $this->set_percent($total_percent); |
|
1007 | + } elseif ($this->is_total()) { |
|
1008 | + foreach ($this->children() as $maybe_tax_subtotal) { |
|
1009 | + if ($maybe_tax_subtotal instanceof EE_Line_Item) { |
|
1010 | 1010 | $maybe_tax_subtotal->_recalculate_tax_sub_total(); |
1011 | 1011 | } |
1012 | 1012 | } |
@@ -1022,8 +1022,8 @@ discard block |
||
1022 | 1022 | public function get_total_tax() { |
1023 | 1023 | $this->_recalculate_tax_sub_total(); |
1024 | 1024 | $total = 0; |
1025 | - foreach ( $this->tax_descendants() as $tax_line_item ) { |
|
1026 | - if ( $tax_line_item instanceof EE_Line_Item ) { |
|
1025 | + foreach ($this->tax_descendants() as $tax_line_item) { |
|
1026 | + if ($tax_line_item instanceof EE_Line_Item) { |
|
1027 | 1027 | $total += $tax_line_item->total(); |
1028 | 1028 | } |
1029 | 1029 | } |
@@ -1037,15 +1037,15 @@ discard block |
||
1037 | 1037 | */ |
1038 | 1038 | public function get_items_total() { |
1039 | 1039 | //by default, let's make sure we're consistent with the existing line item |
1040 | - if( $this->is_total() ) { |
|
1041 | - $pretax_subtotal_li = EEH_Line_Item::get_pre_tax_subtotal( $this ); |
|
1042 | - if( $pretax_subtotal_li instanceof EE_Line_Item ) { |
|
1040 | + if ($this->is_total()) { |
|
1041 | + $pretax_subtotal_li = EEH_Line_Item::get_pre_tax_subtotal($this); |
|
1042 | + if ($pretax_subtotal_li instanceof EE_Line_Item) { |
|
1043 | 1043 | return $pretax_subtotal_li->total(); |
1044 | 1044 | } |
1045 | 1045 | } |
1046 | 1046 | $total = 0; |
1047 | - foreach ( $this->get_items() as $item ) { |
|
1048 | - if ( $item instanceof EE_Line_Item ) { |
|
1047 | + foreach ($this->get_items() as $item) { |
|
1048 | + if ($item instanceof EE_Line_Item) { |
|
1049 | 1049 | $total += $item->total(); |
1050 | 1050 | } |
1051 | 1051 | } |
@@ -1060,8 +1060,8 @@ discard block |
||
1060 | 1060 | * @return EE_Line_Item[] |
1061 | 1061 | */ |
1062 | 1062 | function tax_descendants() { |
1063 | - EE_Registry::instance()->load_helper( 'Line_Item' ); |
|
1064 | - return EEH_Line_Item::get_tax_descendants( $this ); |
|
1063 | + EE_Registry::instance()->load_helper('Line_Item'); |
|
1064 | + return EEH_Line_Item::get_tax_descendants($this); |
|
1065 | 1065 | } |
1066 | 1066 | |
1067 | 1067 | |
@@ -1071,8 +1071,8 @@ discard block |
||
1071 | 1071 | * @return EE_Line_Item[] |
1072 | 1072 | */ |
1073 | 1073 | function get_items() { |
1074 | - EE_Registry::instance()->load_helper( 'Line_Item' ); |
|
1075 | - return EEH_Line_Item::get_line_item_descendants( $this ); |
|
1074 | + EE_Registry::instance()->load_helper('Line_Item'); |
|
1075 | + return EEH_Line_Item::get_line_item_descendants($this); |
|
1076 | 1076 | } |
1077 | 1077 | |
1078 | 1078 | |
@@ -1086,22 +1086,22 @@ discard block |
||
1086 | 1086 | */ |
1087 | 1087 | function taxable_total() { |
1088 | 1088 | $total = 0; |
1089 | - if ( $this->children() ) { |
|
1090 | - foreach ( $this->children() as $child_line_item ) { |
|
1091 | - if ( $child_line_item->type() == EEM_Line_Item::type_line_item && $child_line_item->is_taxable()) { |
|
1089 | + if ($this->children()) { |
|
1090 | + foreach ($this->children() as $child_line_item) { |
|
1091 | + if ($child_line_item->type() == EEM_Line_Item::type_line_item && $child_line_item->is_taxable()) { |
|
1092 | 1092 | //if it's a percent item, only take into account the percent |
1093 | 1093 | //that's taxable too (the taxable total so far) |
1094 | - if( $child_line_item->is_percent() ) { |
|
1095 | - $total = $total + ( $total * $child_line_item->percent() / 100 ); |
|
1096 | - }else{ |
|
1094 | + if ($child_line_item->is_percent()) { |
|
1095 | + $total = $total + ($total * $child_line_item->percent() / 100); |
|
1096 | + } else { |
|
1097 | 1097 | $total += $child_line_item->total(); |
1098 | 1098 | } |
1099 | - }elseif( $child_line_item->type() == EEM_Line_Item::type_sub_total ){ |
|
1099 | + }elseif ($child_line_item->type() == EEM_Line_Item::type_sub_total) { |
|
1100 | 1100 | $total += $child_line_item->taxable_total(); |
1101 | 1101 | } |
1102 | 1102 | } |
1103 | 1103 | } |
1104 | - return max( $total, 0 ); |
|
1104 | + return max($total, 0); |
|
1105 | 1105 | } |
1106 | 1106 | |
1107 | 1107 | |
@@ -1111,7 +1111,7 @@ discard block |
||
1111 | 1111 | * @return EE_Transaction |
1112 | 1112 | */ |
1113 | 1113 | public function transaction() { |
1114 | - return $this->get_first_related( 'Transaction' ); |
|
1114 | + return $this->get_first_related('Transaction'); |
|
1115 | 1115 | } |
1116 | 1116 | |
1117 | 1117 | |
@@ -1124,17 +1124,17 @@ discard block |
||
1124 | 1124 | * @param int $txn_id if none is provided, assumes $this->TXN_ID() |
1125 | 1125 | * @return int count of items saved |
1126 | 1126 | */ |
1127 | - public function save_this_and_descendants_to_txn( $txn_id = NULL ) { |
|
1128 | - if ( ! $txn_id ) { |
|
1127 | + public function save_this_and_descendants_to_txn($txn_id = NULL) { |
|
1128 | + if ( ! $txn_id) { |
|
1129 | 1129 | $txn_id = $this->TXN_ID(); |
1130 | 1130 | } |
1131 | - $this->set_TXN_ID( $txn_id ); |
|
1131 | + $this->set_TXN_ID($txn_id); |
|
1132 | 1132 | $children = $this->children(); |
1133 | 1133 | $this->save(); |
1134 | - foreach ( $children as $child_line_item ) { |
|
1135 | - if ( $child_line_item instanceof EE_Line_Item ) { |
|
1136 | - $child_line_item->set_parent_ID( $this->ID() ); |
|
1137 | - $child_line_item->save_this_and_descendants_to_txn( $txn_id ); |
|
1134 | + foreach ($children as $child_line_item) { |
|
1135 | + if ($child_line_item instanceof EE_Line_Item) { |
|
1136 | + $child_line_item->set_parent_ID($this->ID()); |
|
1137 | + $child_line_item->save_this_and_descendants_to_txn($txn_id); |
|
1138 | 1138 | } |
1139 | 1139 | } |
1140 | 1140 | } |
@@ -1146,10 +1146,10 @@ discard block |
||
1146 | 1146 | * @param string $type one of the constants on EEM_Line_Item |
1147 | 1147 | * @return EE_Line_Item[] |
1148 | 1148 | */ |
1149 | - protected function _get_descendants_of_type( $type ) { |
|
1150 | - EE_Error::doing_it_wrong( 'EE_Line_Item::_get_descendants_of_type()', __('Method replaced with EEH_Line_Item::get_descendants_of_type()', 'event_espresso'), '4.6.0' ); |
|
1151 | - EE_Registry::instance()->load_helper( 'Line_Item' ); |
|
1152 | - return EEH_Line_Item::get_descendants_of_type( $this, $type ); |
|
1149 | + protected function _get_descendants_of_type($type) { |
|
1150 | + EE_Error::doing_it_wrong('EE_Line_Item::_get_descendants_of_type()', __('Method replaced with EEH_Line_Item::get_descendants_of_type()', 'event_espresso'), '4.6.0'); |
|
1151 | + EE_Registry::instance()->load_helper('Line_Item'); |
|
1152 | + return EEH_Line_Item::get_descendants_of_type($this, $type); |
|
1153 | 1153 | } |
1154 | 1154 | |
1155 | 1155 | |
@@ -1159,10 +1159,10 @@ discard block |
||
1159 | 1159 | * @param string $type like one of the EEM_Line_Item::type_* |
1160 | 1160 | * @return EE_Line_Item |
1161 | 1161 | */ |
1162 | - public function get_nearest_descendant_of_type( $type ) { |
|
1163 | - EE_Error::doing_it_wrong( 'EE_Line_Item::get_nearest_descendant_of_type()', __('Method replaced with EEH_Line_Item::get_nearest_descendant_of_type()', 'event_espresso'), '4.6.0' ); |
|
1164 | - EE_Registry::instance()->load_helper( 'Line_Item' ); |
|
1165 | - return EEH_Line_Item::get_nearest_descendant_of_type( $this, $type ); |
|
1162 | + public function get_nearest_descendant_of_type($type) { |
|
1163 | + EE_Error::doing_it_wrong('EE_Line_Item::get_nearest_descendant_of_type()', __('Method replaced with EEH_Line_Item::get_nearest_descendant_of_type()', 'event_espresso'), '4.6.0'); |
|
1164 | + EE_Registry::instance()->load_helper('Line_Item'); |
|
1165 | + return EEH_Line_Item::get_nearest_descendant_of_type($this, $type); |
|
1166 | 1166 | } |
1167 | 1167 | |
1168 | 1168 | |
@@ -1173,7 +1173,7 @@ discard block |
||
1173 | 1173 | * @return int count of items saved |
1174 | 1174 | */ |
1175 | 1175 | public function maybe_save() { |
1176 | - if ( $this->ID() ) { |
|
1176 | + if ($this->ID()) { |
|
1177 | 1177 | return $this->save(); |
1178 | 1178 | } |
1179 | 1179 | return false; |