You are here

function uc_payment_uc_order_delete in Ubercart 8.4

Implements hook_uc_order_delete().

File

payment/uc_payment/uc_payment.module, line 247
Defines the payment API that lets payment modules interact with Ubercart.

Code

function uc_payment_uc_order_delete(OrderInterface $order) {
  $result = \Drupal::entityQuery('uc_payment_receipt')
    ->condition('order_id', $order
    ->id())
    ->execute();
  if (!empty($result)) {
    $storage = \Drupal::entityTypeManager()
      ->getStorage('uc_payment_receipt');
    $entities = $storage
      ->loadMultiple(array_keys($result));
    $storage
      ->delete($entities);
  }

  // Call each payment method to delete method-specific data from the database.
  foreach (uc_payment_method_list() as $id => $method) {
    \Drupal::service('plugin.manager.uc_payment.method')
      ->createInstance($id)
      ->orderDelete($order);
  }
}