|
@@ 586-599 (lines=14) @@
|
| 583 |
|
// and removing the ticket from datetimes it got removed from. |
| 584 |
|
|
| 585 |
|
// first let's add datetimes |
| 586 |
|
if ( ! empty( $added_datetimes ) && is_array( $added_datetimes ) ) { |
| 587 |
|
foreach ( $added_datetimes as $row_id ) { |
| 588 |
|
$row_id = (int) $row_id; |
| 589 |
|
if ( isset( $saved_datetimes[ $row_id ] ) && $saved_datetimes[ $row_id ] instanceof EE_Datetime ) { |
| 590 |
|
$ticket->_add_relation_to( $saved_datetimes[ $row_id ], 'Datetime' ); |
| 591 |
|
// Is this an existing ticket (has an ID) and does it have any sold? |
| 592 |
|
// If so, then we need to add that to the DTT sold because this DTT is getting added. |
| 593 |
|
if ( $ticket->ID() && $ticket->sold() > 0 ) { |
| 594 |
|
$saved_datetimes[ $row_id ]->increase_sold( $ticket->sold() ); |
| 595 |
|
$saved_datetimes[ $row_id ]->save(); |
| 596 |
|
} |
| 597 |
|
} |
| 598 |
|
} |
| 599 |
|
} |
| 600 |
|
// then remove datetimes |
| 601 |
|
if ( ! empty( $removed_datetimes ) && is_array( $removed_datetimes ) ) { |
| 602 |
|
foreach ( $removed_datetimes as $row_id ) { |
|
@@ 601-616 (lines=16) @@
|
| 598 |
|
} |
| 599 |
|
} |
| 600 |
|
// then remove datetimes |
| 601 |
|
if ( ! empty( $removed_datetimes ) && is_array( $removed_datetimes ) ) { |
| 602 |
|
foreach ( $removed_datetimes as $row_id ) { |
| 603 |
|
$row_id = (int)$row_id; |
| 604 |
|
// its entirely possible that a datetime got deleted (instead of just removed from relationship. |
| 605 |
|
// So make sure we skip over this if the dtt isn't in the $saved_datetimes array) |
| 606 |
|
if ( isset( $saved_datetimes[ $row_id ] ) && $saved_datetimes[ $row_id ] instanceof EE_Datetime ) { |
| 607 |
|
$ticket->_remove_relation_to( $saved_datetimes[ $row_id ], 'Datetime' ); |
| 608 |
|
// Is this an existing ticket (has an ID) and does it have any sold? |
| 609 |
|
// If so, then we need to remove it's sold from the DTT_sold. |
| 610 |
|
if ( $ticket->ID() && $ticket->sold() > 0 ) { |
| 611 |
|
$saved_datetimes[ $row_id ]->decrease_sold( $ticket->sold() ); |
| 612 |
|
$saved_datetimes[ $row_id ]->save(); |
| 613 |
|
} |
| 614 |
|
} |
| 615 |
|
} |
| 616 |
|
} |
| 617 |
|
// cap ticket qty by datetime reg limits |
| 618 |
|
$ticket->set_qty( min( $ticket->qty(), $ticket->qty( 'reg_limit' ) ) ); |
| 619 |
|
return $ticket; |