Commit 4b523f9c authored by Adrian Vazquez's avatar Adrian Vazquez Committed by Pedro Cambra
Browse files

Issue #3192100 by thetwentyseven, pcambra: Error: Call to a member function...

Issue #3192100 by thetwentyseven, pcambra: Error: Call to a member function get() on null - when removing orders that have tickets attached
parent 914911b6
Loading
Loading
Loading
Loading
+9 −7
Original line number Diff line number Diff line
@@ -72,11 +72,12 @@ class TicketSubscriber implements EventSubscriberInterface {
   * @param \Drupal\commerce_ticketing\Event\TicketEvent $event
   *   The event.
   *
   * @throws \Drupal\Core\Entity\EntityStorageException
   */
  public function removeFromOrder(TicketEvent $event) {
    /** @var \Drupal\commerce_ticketing\CommerceTicketInterface $ticket */
    $ticket = $event->getTicket();
    $order = $ticket->getOrder();
    if ($order){
      $existing_tickets = $order->get('tickets')->getValue();
      foreach ($existing_tickets as $key => $existing_ticket) {
        if ($existing_ticket['target_id'] == $ticket->id()) {
@@ -86,5 +87,6 @@ class TicketSubscriber implements EventSubscriberInterface {

      $order->save();
    }
  }

}