You are here

function uc_order_comment_save in Ubercart 8.4

Same name and namespace in other branches
  1. 5 uc_order/uc_order.module \uc_order_comment_save()
  2. 6.2 uc_order/uc_order.module \uc_order_comment_save()
  3. 7.3 uc_order/uc_order.module \uc_order_comment_save()

Inserts a comment, $type being either 'order' or 'admin'.

23 calls to uc_order_comment_save()
AddOrderComment::doExecute in uc_order/src/Plugin/RulesAction/AddOrderComment.php
Adds a comment to an order.
AdminComments::submitForm in uc_order/src/Plugin/Ubercart/OrderPane/AdminComments.php
Form submission handler.
AuthorizeNet::_uc_authorizenet_charge in payment/uc_authorizenet/src/Plugin/Ubercart/PaymentMethod/AuthorizeNet.php
Handles authorizations and captures through AIM at Authorize.Net.
CheckoutController::complete in uc_cart/src/Controller/CheckoutController.php
Completes the sale and finishes checkout.
CheckoutForm::cancel in uc_cart/src/Form/CheckoutForm.php
Submit handler for the "Cancel" button on the checkout form.

... See full list

File

uc_order/uc_order.module, line 287
Handles all things concerning Ubercart orders.

Code

function uc_order_comment_save($order_id, $uid, $message, $type = 'admin', $status = 'pending', $notify = FALSE) {
  $order = Order::load($order_id);
  $event = new OrderCommentAddedEvent($order);
  \Drupal::service('event_dispatcher')
    ->dispatch($event::EVENT_NAME, $event);
  $connection = \Drupal::database();
  if ($type == 'admin') {
    $connection
      ->insert('uc_order_admin_comments')
      ->fields([
      'order_id' => $order_id,
      'uid' => $uid,
      'message' => $message,
      'created' => \Drupal::time()
        ->getRequestTime(),
    ])
      ->execute();
  }
  elseif ($type == 'order') {
    $connection
      ->insert('uc_order_comments')
      ->fields([
      'order_id' => $order_id,
      'uid' => $uid,
      'message' => $message,
      'order_status' => $status,
      'notified' => $notify ? 1 : 0,
      'created' => \Drupal::time()
        ->getRequestTime(),
    ])
      ->execute();
  }
}